forked from microsoft/VFSForGit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiskLayoutVersionTests.cs
More file actions
70 lines (64 loc) · 2.99 KB
/
DiskLayoutVersionTests.cs
File metadata and controls
70 lines (64 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using GVFS.FunctionalTests.Tests.EnlistmentPerTestCase;
using GVFS.FunctionalTests.Tools;
using GVFS.Tests.Should;
using NUnit.Framework;
using System.Runtime.InteropServices;
namespace GVFS.FunctionalTests.Tests
{
[TestFixture]
[Category(Categories.ExtraCoverage)]
public class DiskLayoutVersionTests : TestsWithEnlistmentPerTestCase
{
private const int WindowsCurrentDiskLayoutMajorVersion = 17;
private const int MacCurrentDiskLayoutMajorVersion = 18;
private const int WindowsCurrentDiskLayoutMinimumMajorVersion = 7;
private const int MacCurrentDiskLayoutMinimumMajorVersion = 18;
private const int CurrentDiskLayoutMinorVersion = 0;
private int currentDiskMajorVersion;
private int currentDiskMinimumMajorVersion;
[SetUp]
public override void CreateEnlistment()
{
base.CreateEnlistment();
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
this.currentDiskMajorVersion = MacCurrentDiskLayoutMajorVersion;
this.currentDiskMinimumMajorVersion = MacCurrentDiskLayoutMinimumMajorVersion;
}
else
{
this.currentDiskMajorVersion = WindowsCurrentDiskLayoutMajorVersion;
this.currentDiskMinimumMajorVersion = WindowsCurrentDiskLayoutMinimumMajorVersion;
}
}
[TestCase]
public void MountSucceedsIfMinorVersionHasAdvancedButNotMajorVersion()
{
// Advance the minor version, mount should still work
this.Enlistment.UnmountGVFS();
GVFSHelpers.SaveDiskLayoutVersion(
this.Enlistment.DotGVFSRoot,
this.currentDiskMajorVersion.ToString(),
(CurrentDiskLayoutMinorVersion + 1).ToString());
this.Enlistment.TryMountGVFS().ShouldBeTrue("Mount should succeed because only the minor version advanced");
// Advance the major version, mount should fail
this.Enlistment.UnmountGVFS();
GVFSHelpers.SaveDiskLayoutVersion(
this.Enlistment.DotGVFSRoot,
(this.currentDiskMajorVersion + 1).ToString(),
CurrentDiskLayoutMinorVersion.ToString());
this.Enlistment.TryMountGVFS().ShouldBeFalse("Mount should fail because the major version has advanced");
}
[TestCase]
public void MountFailsIfBeforeMinimumVersion()
{
// Mount should fail if on disk version is below minimum supported version
this.Enlistment.UnmountGVFS();
GVFSHelpers.SaveDiskLayoutVersion(
this.Enlistment.DotGVFSRoot,
(this.currentDiskMinimumMajorVersion - 1).ToString(),
CurrentDiskLayoutMinorVersion.ToString());
this.Enlistment.TryMountGVFS().ShouldBeFalse("Mount should fail because we are before minimum version");
}
}
}