Files
VirtualFS/VirtualFS.Tests/PathTests.cs

46 lines
1.0 KiB
C#

namespace VirtualFS.Tests;
public class PathTests
{
[Fact]
public void PathCast()
{
Path path = "/test/path";
Assert.NotNull(path);
Assert.Equal("/test/path", (string)path);
}
[Fact]
public void FileAndDirectoryPathsDiffer()
{
Assert.False(((Path)"/test/path").IsDirectory == ((Path)"/test/path/").IsDirectory);
}
[Fact]
public void AppendCombinesDirectoryAndName()
{
Assert.Equal((Path)"/test/path/SomeFile.txt", ((Path)"/test/path/") + "SomeFile.txt");
}
[Fact]
public void ExtensionIsReadFromFilePath()
{
Assert.Equal("txt", ((Path)"/test/path/SomeFile.txt").GetExtension());
}
[Fact]
public void ParentIsResolvedCorrectly()
{
Assert.Null(new Path().Parent);
Assert.Equal(new Path(), ((Path)"/test/").Parent);
Assert.Equal((Path)"/test/", ((Path)"/test/path/").Parent);
}
[Fact]
public void InvalidPathThrows()
{
Assert.Throws<InvalidOperationException>(() => new Path("test"));
}
}