Initial commit
This commit is contained in:
47
VirtualFS.Tests/PathTests.cs
Normal file
47
VirtualFS.Tests/PathTests.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace VirtualFS.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class PathTests
|
||||
{
|
||||
[TestMethod]
|
||||
public virtual void TestPathCast()
|
||||
{
|
||||
Path p = "/test/path";
|
||||
|
||||
Assert.IsNotNull(p);
|
||||
Assert.AreEqual("/test/path", (string)p);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public virtual void TestPathDirectoryNotDirectory()
|
||||
{
|
||||
Assert.IsFalse(((Path)"/test/path").IsDirectory == ((Path)"/test/path/").IsDirectory);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public virtual void TestPathAddPath()
|
||||
{
|
||||
Assert.AreEqual((Path)"/test/path/SomeFile.txt", ((Path)"/test/path/") + "SomeFile.txt");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public virtual void TestPathExt()
|
||||
{
|
||||
Assert.AreEqual("txt", ((Path)"/test/path/SomeFile.txt").GetExtension());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public virtual void TestPathParent()
|
||||
{
|
||||
Assert.IsNull(new Path().Parent);
|
||||
Assert.AreEqual(new Path(), ((Path)"/test/").Parent);
|
||||
Assert.AreEqual((Path)"/test/", ((Path)"/test/path/").Parent);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public virtual void TestInvalidPath()
|
||||
{
|
||||
Assert.ThrowsException<InvalidOperationException>(() => new Path("test"));
|
||||
}
|
||||
}
|
||||
}
|
||||
14
VirtualFS.Tests/Physical/PhysicalFileSystemTests.cs
Normal file
14
VirtualFS.Tests/Physical/PhysicalFileSystemTests.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using VirtualFS.Physical;
|
||||
|
||||
namespace VirtualFS.Tests.Physical
|
||||
{
|
||||
[TestClass]
|
||||
public class PhysicalFileSystemTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestEnumerate()
|
||||
{
|
||||
Assert.IsTrue(new PhysicalFileSystem(new System.IO.DirectoryInfo("C:\\")).GetEntries("/").Count() > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
VirtualFS.Tests/RootFileSystemTest.cs
Normal file
44
VirtualFS.Tests/RootFileSystemTest.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using VirtualFS.Implementation;
|
||||
using VirtualFS.Physical;
|
||||
|
||||
namespace VirtualFS.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class RootFileSystemTest
|
||||
{
|
||||
private RootFileSystem _root;
|
||||
private string _realRootPath = "C:\\Temp\\";
|
||||
|
||||
[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\\"));
|
||||
}
|
||||
}
|
||||
}
|
||||
27
VirtualFS.Tests/VirtualFS.Tests.csproj
Normal file
27
VirtualFS.Tests/VirtualFS.Tests.csproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VirtualFS\VirtualFS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user