Modernize project targets and Docker test flow
This commit is contained in:
@@ -1,44 +1,51 @@
|
||||
using VirtualFS.Implementation;
|
||||
using VirtualFS.Physical;
|
||||
|
||||
namespace VirtualFS.Tests
|
||||
namespace VirtualFS.Tests;
|
||||
|
||||
public sealed class RootFileSystemTests : IDisposable
|
||||
{
|
||||
[TestClass]
|
||||
public class RootFileSystemTest
|
||||
private readonly string _realRootPath;
|
||||
private readonly RootFileSystem _root;
|
||||
|
||||
public RootFileSystemTests()
|
||||
{
|
||||
private RootFileSystem _root;
|
||||
private string _realRootPath = "C:\\Temp\\";
|
||||
_realRootPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "VirtualFS.Tests", Guid.NewGuid().ToString("N"));
|
||||
System.IO.Directory.CreateDirectory(_realRootPath);
|
||||
|
||||
[TestInitialize]
|
||||
public virtual void SetUp()
|
||||
{
|
||||
if (!System.IO.Directory.Exists(_realRootPath))
|
||||
System.IO.Directory.CreateDirectory(_realRootPath);
|
||||
|
||||
_root = new RootFileSystem();
|
||||
_root.Mount(new PhysicalFileSystem(new System.IO.DirectoryInfo(_realRootPath)), (Path)"/");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public virtual void TestEnumerate()
|
||||
{
|
||||
var root = new RootFileSystem();
|
||||
root.Mount(new PhysicalFileSystem(new System.IO.DirectoryInfo("C:\\")), (Path)"/");
|
||||
root.Mount(new PhysicalFileSystem(new System.IO.DirectoryInfo("C:\\")), (Path)"/");
|
||||
|
||||
Assert.AreEqual(new PhysicalFileSystem(new System.IO.DirectoryInfo("C:\\")).GetEntries("/").Count(), root.GetEntries("/").Count());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public virtual void TestDirectoryCreateAndDelete()
|
||||
{
|
||||
var dir = _root.Root.Create("Test");
|
||||
|
||||
Assert.IsTrue(System.IO.Directory.Exists(_realRootPath + "Test\\"));
|
||||
|
||||
dir.Delete();
|
||||
|
||||
Assert.IsFalse(System.IO.Directory.Exists(_realRootPath + "Test\\"));
|
||||
}
|
||||
_root = new RootFileSystem();
|
||||
_root.Mount(new PhysicalFileSystem(new System.IO.DirectoryInfo(_realRootPath)), (Path)"/");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnumerateMergesMountedEntriesWithoutDuplicates()
|
||||
{
|
||||
var sharedRoot = new System.IO.DirectoryInfo(_realRootPath);
|
||||
System.IO.File.WriteAllText(System.IO.Path.Combine(_realRootPath, "first.txt"), "first");
|
||||
|
||||
var root = new RootFileSystem();
|
||||
root.Mount(new PhysicalFileSystem(sharedRoot), (Path)"/");
|
||||
root.Mount(new PhysicalFileSystem(sharedRoot), (Path)"/");
|
||||
|
||||
Assert.Equal(new PhysicalFileSystem(sharedRoot).GetEntries("/").Count(), root.GetEntries("/").Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DirectoryCreateAndDeleteReflectsOnMountedPhysicalFileSystem()
|
||||
{
|
||||
var dir = _root.Root.Create("Test");
|
||||
var expectedPath = System.IO.Path.Combine(_realRootPath, "Test");
|
||||
|
||||
Assert.True(System.IO.Directory.Exists(expectedPath));
|
||||
|
||||
dir.Delete();
|
||||
|
||||
Assert.False(System.IO.Directory.Exists(expectedPath));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (System.IO.Directory.Exists(_realRootPath))
|
||||
System.IO.Directory.Delete(_realRootPath, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user