wabbajack/Wabbajack.Common.Test/PathTests.cs

45 lines
1.1 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
using Xunit;
2020-04-27 21:32:19 +00:00
namespace Wabbajack.Common.Test
{
public class PathTests
{
[Fact]
public async Task CanDeleteReadOnlyFile()
2020-04-27 21:32:19 +00:00
{
var tempFile = new TempFile();
await tempFile.Path.WriteAllTextAsync("Test");
2020-04-27 21:32:19 +00:00
tempFile.Path.SetReadOnly(true);
tempFile.Path.Delete();
}
[Fact]
public async Task CanMoveReadOnlyFiles()
2020-04-27 21:32:19 +00:00
{
var tempFile = new TempFile();
var tempFile2 = new TempFile();
await tempFile.Path.WriteAllTextAsync("Test");
2020-04-27 21:32:19 +00:00
tempFile.Path.SetReadOnly(true);
await tempFile.Path.MoveToAsync(tempFile2.Path);
2020-04-27 21:32:19 +00:00
}
2020-05-04 12:11:53 +00:00
[Fact]
public void CanGetTopParentOfPath()
{
var path = (RelativePath)"foo/bar";
Assert.Equal((RelativePath)"foo", path.TopParent);
}
[Fact]
public void CanGetTopParentOfSinglePath()
{
var path = (RelativePath)"foo";
Assert.Equal((RelativePath)"foo", path.TopParent);
}
2020-04-27 21:32:19 +00:00
}
}