2020-05-25 16:24:16 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xunit;
|
2020-04-27 21:32:19 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Common.Test
|
|
|
|
|
{
|
|
|
|
|
public class PathTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
2020-05-25 16:24:16 +00:00
|
|
|
|
public async Task CanDeleteReadOnlyFile()
|
2020-04-27 21:32:19 +00:00
|
|
|
|
{
|
|
|
|
|
var tempFile = new TempFile();
|
2020-05-25 16:24:16 +00:00
|
|
|
|
await tempFile.Path.WriteAllTextAsync("Test");
|
2020-04-27 21:32:19 +00:00
|
|
|
|
tempFile.Path.SetReadOnly(true);
|
|
|
|
|
|
2020-05-26 11:31:11 +00:00
|
|
|
|
await tempFile.Path.DeleteAsync();
|
2020-04-27 21:32:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2020-05-25 16:24:16 +00:00
|
|
|
|
public async Task CanMoveReadOnlyFiles()
|
2020-04-27 21:32:19 +00:00
|
|
|
|
{
|
|
|
|
|
var tempFile = new TempFile();
|
|
|
|
|
var tempFile2 = new TempFile();
|
2020-05-25 16:24:16 +00:00
|
|
|
|
await tempFile.Path.WriteAllTextAsync("Test");
|
2020-04-27 21:32:19 +00:00
|
|
|
|
tempFile.Path.SetReadOnly(true);
|
|
|
|
|
|
2020-05-25 16:24:16 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|