mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Use "Result" and "Success" asserts in tests
This commit is contained in:
parent
d04e713356
commit
ff96c8575b
16 changed files with 117 additions and 127 deletions
|
@ -14,9 +14,9 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
{
|
||||
IAttributeFileSystem fs = CreateAttributeFileSystem();
|
||||
|
||||
Assert.True(fs.CreateDirectory("/dir".ToU8Span(), NxFileAttributes.None).IsSuccess());
|
||||
Assert.Success(fs.CreateDirectory("/dir".ToU8Span(), NxFileAttributes.None));
|
||||
|
||||
Assert.True(fs.GetFileAttributes(out NxFileAttributes attributes, "/dir".ToU8Span()).IsSuccess());
|
||||
Assert.Success(fs.GetFileAttributes(out NxFileAttributes attributes, "/dir".ToU8Span()));
|
||||
Assert.Equal(NxFileAttributes.Directory, attributes);
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,9 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
{
|
||||
IAttributeFileSystem fs = CreateAttributeFileSystem();
|
||||
|
||||
Assert.True(fs.CreateDirectory("/dir".ToU8Span(), NxFileAttributes.Archive).IsSuccess());
|
||||
Assert.Success(fs.CreateDirectory("/dir".ToU8Span(), NxFileAttributes.Archive));
|
||||
|
||||
Assert.True(fs.GetFileAttributes(out NxFileAttributes attributes, "/dir".ToU8Span()).IsSuccess());
|
||||
Assert.Success(fs.GetFileAttributes(out NxFileAttributes attributes, "/dir".ToU8Span()));
|
||||
Assert.Equal(NxFileAttributes.Directory | NxFileAttributes.Archive, attributes);
|
||||
}
|
||||
|
||||
|
@ -37,9 +37,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
IAttributeFileSystem fs = CreateAttributeFileSystem();
|
||||
fs.CreateFile("/file".ToU8Span(), 0, CreateFileOptions.None);
|
||||
|
||||
Result rc = fs.GetFileAttributes(out NxFileAttributes attributes, "/file".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(fs.GetFileAttributes(out NxFileAttributes attributes, "/file".ToU8Span()));
|
||||
Assert.Equal(NxFileAttributes.None, attributes);
|
||||
}
|
||||
|
||||
|
@ -49,9 +47,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
IAttributeFileSystem fs = CreateAttributeFileSystem();
|
||||
fs.CreateDirectory("/dir".ToU8Span());
|
||||
|
||||
Result rc = fs.GetFileAttributes(out NxFileAttributes attributes, "/dir".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(fs.GetFileAttributes(out NxFileAttributes attributes, "/dir".ToU8Span()));
|
||||
Assert.Equal(NxFileAttributes.Directory, attributes);
|
||||
}
|
||||
|
||||
|
@ -62,7 +58,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.GetFileAttributes(out _, "/path".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -72,7 +68,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.SetFileAttributes("/path".ToU8Span(), NxFileAttributes.None);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -84,8 +80,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcSet = fs.SetFileAttributes("/file".ToU8Span(), NxFileAttributes.Archive);
|
||||
Result rcGet = fs.GetFileAttributes(out NxFileAttributes attributes, "/file".ToU8Span());
|
||||
|
||||
Assert.True(rcSet.IsSuccess());
|
||||
Assert.True(rcGet.IsSuccess());
|
||||
Assert.Success(rcSet);
|
||||
Assert.Success(rcGet);
|
||||
Assert.Equal(NxFileAttributes.Archive, attributes);
|
||||
}
|
||||
|
||||
|
@ -98,8 +94,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcSet = fs.SetFileAttributes("/dir".ToU8Span(), NxFileAttributes.Archive);
|
||||
Result rcGet = fs.GetFileAttributes(out NxFileAttributes attributes, "/dir".ToU8Span());
|
||||
|
||||
Assert.True(rcSet.IsSuccess());
|
||||
Assert.True(rcGet.IsSuccess());
|
||||
Assert.Success(rcSet);
|
||||
Assert.Success(rcGet);
|
||||
Assert.Equal(NxFileAttributes.Directory | NxFileAttributes.Archive, attributes);
|
||||
}
|
||||
|
||||
|
@ -110,7 +106,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
fs.CreateFile("/file".ToU8Span(), 845, CreateFileOptions.None);
|
||||
|
||||
Assert.True(fs.GetFileSize(out long fileSize, "/file".ToU8Span()).IsSuccess());
|
||||
Assert.Success(fs.GetFileSize(out long fileSize, "/file".ToU8Span()));
|
||||
Assert.Equal(845, fileSize);
|
||||
}
|
||||
|
||||
|
@ -121,7 +117,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.GetFileSize(out _, "/path".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -132,7 +128,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.GetFileSize(out _, "/dir".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDir2Type = fs.GetEntryType(out _, "/dir/dir2".ToU8Span());
|
||||
Result rcFileType = fs.GetEntryType(out _, "/dir/file1".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.Success(rcDelete);
|
||||
|
||||
Assert.True(rcDir1Type.IsSuccess());
|
||||
Assert.Success(rcDir1Type);
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir1Type);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcDir2Type);
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcFileType);
|
||||
Assert.Result(ResultFs.PathNotFound, rcDir2Type);
|
||||
Assert.Result(ResultFs.PathNotFound, rcFileType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,9 +13,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
IFileSystem fs = CreateFileSystem();
|
||||
|
||||
fs.CreateDirectory("/dir".ToU8Span());
|
||||
Result rc = fs.GetEntryType(out DirectoryEntryType type, "/dir".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "/dir".ToU8Span()));
|
||||
Assert.Equal(DirectoryEntryType.Directory, type);
|
||||
}
|
||||
|
||||
|
@ -28,7 +27,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.CreateDirectory("/dir".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathAlreadyExists.Value, rc);
|
||||
Assert.Result(ResultFs.PathAlreadyExists, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -40,7 +39,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.CreateDirectory("/file".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathAlreadyExists.Value, rc);
|
||||
Assert.Result(ResultFs.PathAlreadyExists, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -50,7 +49,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.CreateFile("/dir1/dir2".ToU8Span(), 0, CreateFileOptions.None);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -61,7 +60,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.CreateDirectory("/dir/".ToU8Span());
|
||||
Result rc = fs.GetEntryType(out DirectoryEntryType type, "/dir/".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(rc);
|
||||
Assert.Equal(DirectoryEntryType.Directory, type);
|
||||
}
|
||||
|
||||
|
@ -76,8 +75,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rc1 = fs.GetEntryType(out DirectoryEntryType type1, "/dir1".ToU8Span());
|
||||
Result rc2 = fs.GetEntryType(out DirectoryEntryType type2, "/dir2".ToU8Span());
|
||||
|
||||
Assert.True(rc1.IsSuccess());
|
||||
Assert.True(rc2.IsSuccess());
|
||||
Assert.Success(rc1);
|
||||
Assert.Success(rc2);
|
||||
Assert.Equal(DirectoryEntryType.Directory, type1);
|
||||
Assert.Equal(DirectoryEntryType.Directory, type2);
|
||||
}
|
||||
|
@ -96,8 +95,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rc1 = fs.GetEntryType(out DirectoryEntryType type1, "/dir1/dir1a".ToU8Span());
|
||||
Result rc2 = fs.GetEntryType(out DirectoryEntryType type2, "/dir2/dir2a".ToU8Span());
|
||||
|
||||
Assert.True(rc1.IsSuccess());
|
||||
Assert.True(rc2.IsSuccess());
|
||||
Assert.Success(rc1);
|
||||
Assert.Success(rc2);
|
||||
Assert.Equal(DirectoryEntryType.Directory, type1);
|
||||
Assert.Equal(DirectoryEntryType.Directory, type2);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.CreateFile("/file".ToU8Span(), 0, CreateFileOptions.None);
|
||||
Result rc = fs.GetEntryType(out DirectoryEntryType type, "/file".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(rc);
|
||||
Assert.Equal(DirectoryEntryType.File, type);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.CreateFile("/dir".ToU8Span(), 0, CreateFileOptions.None);
|
||||
|
||||
Assert.Equal(ResultFs.PathAlreadyExists.Value, rc);
|
||||
Assert.Result(ResultFs.PathAlreadyExists, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -40,7 +40,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.CreateFile("/file".ToU8Span(), 0, CreateFileOptions.None);
|
||||
|
||||
Assert.Equal(ResultFs.PathAlreadyExists.Value, rc);
|
||||
Assert.Result(ResultFs.PathAlreadyExists, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -50,7 +50,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.CreateFile("/dir/file".ToU8Span(), 0, CreateFileOptions.None);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -59,9 +59,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
IFileSystem fs = CreateFileSystem();
|
||||
|
||||
fs.CreateFile("/file/".ToU8Span(), 0, CreateFileOptions.None);
|
||||
Result rc = fs.GetEntryType(out DirectoryEntryType type, "/file/".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "/file/".ToU8Span()));
|
||||
Assert.Equal(DirectoryEntryType.File, type);
|
||||
}
|
||||
|
||||
|
@ -75,9 +74,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.CreateFile("/file".ToU8Span(), expectedSize, CreateFileOptions.None);
|
||||
|
||||
fs.OpenFile(out IFile file, "/file".ToU8Span(), OpenMode.Read);
|
||||
Result rc = file.GetSize(out long fileSize);
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(file.GetSize(out long fileSize));
|
||||
Assert.Equal(expectedSize, fileSize);
|
||||
}
|
||||
|
||||
|
@ -92,8 +90,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rc1 = fs.GetEntryType(out DirectoryEntryType type1, "/file1".ToU8Span());
|
||||
Result rc2 = fs.GetEntryType(out DirectoryEntryType type2, "/file2".ToU8Span());
|
||||
|
||||
Assert.True(rc1.IsSuccess());
|
||||
Assert.True(rc2.IsSuccess());
|
||||
Assert.Success(rc1);
|
||||
Assert.Success(rc2);
|
||||
Assert.Equal(DirectoryEntryType.File, type1);
|
||||
Assert.Equal(DirectoryEntryType.File, type2);
|
||||
}
|
||||
|
@ -112,8 +110,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rc1 = fs.GetEntryType(out DirectoryEntryType type1, "/dir1/file1".ToU8Span());
|
||||
Result rc2 = fs.GetEntryType(out DirectoryEntryType type2, "/dir2/file2".ToU8Span());
|
||||
|
||||
Assert.True(rc1.IsSuccess());
|
||||
Assert.True(rc2.IsSuccess());
|
||||
Assert.Success(rc1);
|
||||
Assert.Success(rc2);
|
||||
Assert.Equal(DirectoryEntryType.File, type1);
|
||||
Assert.Equal(DirectoryEntryType.File, type2);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.DeleteDirectory("/dir".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -27,8 +27,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDelete = fs.DeleteDirectory("/dir".ToU8Span());
|
||||
Result rcEntry = fs.GetEntryType(out _, "/dir".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcEntry);
|
||||
Assert.Success(rcDelete);
|
||||
Assert.Result(ResultFs.PathNotFound, rcEntry);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -40,7 +40,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.DeleteDirectory("/file".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -55,9 +55,9 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcEntry1 = fs.GetEntryType(out DirectoryEntryType dir1Type, "/dir1".ToU8Span());
|
||||
Result rcEntry2 = fs.GetEntryType(out _, "/dir2".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.True(rcEntry1.IsSuccess());
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcEntry2);
|
||||
Assert.Success(rcDelete);
|
||||
Assert.Success(rcEntry1);
|
||||
Assert.Result(ResultFs.PathNotFound, rcEntry2);
|
||||
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir1Type);
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcEntry1 = fs.GetEntryType(out DirectoryEntryType dir1Type, "/dir1".ToU8Span());
|
||||
Result rcEntry2 = fs.GetEntryType(out _, "/dir2".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.True(rcEntry1.IsSuccess());
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcEntry2);
|
||||
Assert.Success(rcDelete);
|
||||
Assert.Success(rcEntry1);
|
||||
Assert.Result(ResultFs.PathNotFound, rcEntry2);
|
||||
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir1Type);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.DeleteDirectory("/dir".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.DirectoryNotEmpty.Value, rc);
|
||||
Assert.Result(ResultFs.DirectoryNotEmpty, rc);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,11 +22,11 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDir2Type = fs.GetEntryType(out _, "/dir/dir2".ToU8Span());
|
||||
Result rcFileType = fs.GetEntryType(out _, "/dir/file1".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.Success(rcDelete);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcDir1Type);
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcDir2Type);
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcFileType);
|
||||
Assert.Result(ResultFs.PathNotFound, rcDir1Type);
|
||||
Assert.Result(ResultFs.PathNotFound, rcDir2Type);
|
||||
Assert.Result(ResultFs.PathNotFound, rcFileType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
IFileSystem fs = CreateFileSystem();
|
||||
|
||||
Result rc = fs.DeleteFile("/file".ToU8Span());
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -26,8 +26,8 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDelete = fs.DeleteFile("/file".ToU8Span());
|
||||
Result rcEntry = fs.GetEntryType(out _, "/file".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcEntry);
|
||||
Assert.Success(rcDelete);
|
||||
Assert.Result(ResultFs.PathNotFound, rcEntry);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -39,7 +39,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.DeleteFile("/dir".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -54,9 +54,9 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcEntry1 = fs.GetEntryType(out DirectoryEntryType dir1Type, "/file1".ToU8Span());
|
||||
Result rcEntry2 = fs.GetEntryType(out _, "/file2".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.True(rcEntry1.IsSuccess());
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcEntry2);
|
||||
Assert.Success(rcDelete);
|
||||
Assert.Success(rcEntry1);
|
||||
Assert.Result(ResultFs.PathNotFound, rcEntry2);
|
||||
|
||||
Assert.Equal(DirectoryEntryType.File, dir1Type);
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcEntry1 = fs.GetEntryType(out DirectoryEntryType dir1Type, "/file1".ToU8Span());
|
||||
Result rcEntry2 = fs.GetEntryType(out _, "/file2".ToU8Span());
|
||||
|
||||
Assert.True(rcDelete.IsSuccess());
|
||||
Assert.True(rcEntry1.IsSuccess());
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcEntry2);
|
||||
Assert.Success(rcDelete);
|
||||
Assert.Success(rcEntry1);
|
||||
Assert.Result(ResultFs.PathNotFound, rcEntry2);
|
||||
|
||||
Assert.Equal(DirectoryEntryType.File, dir1Type);
|
||||
}
|
||||
|
|
|
@ -41,18 +41,17 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.CreateFile("/dir/file1".ToU8Span(), 0, CreateFileOptions.None);
|
||||
fs.CreateFile("/dir/file2".ToU8Span(), 0, CreateFileOptions.None);
|
||||
|
||||
Result rc = fs.OpenDirectory(out IDirectory dir, "/dir".ToU8Span(), OpenDirectoryMode.All);
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(fs.OpenDirectory(out IDirectory dir, "/dir".ToU8Span(), OpenDirectoryMode.All));
|
||||
|
||||
var entry1 = new DirectoryEntry();
|
||||
var entry2 = new DirectoryEntry();
|
||||
var entry3 = new DirectoryEntry();
|
||||
var entry4 = new DirectoryEntry();
|
||||
|
||||
Assert.True(dir.Read(out long entriesRead1, SpanHelpers.AsSpan(ref entry1)).IsSuccess());
|
||||
Assert.True(dir.Read(out long entriesRead2, SpanHelpers.AsSpan(ref entry2)).IsSuccess());
|
||||
Assert.True(dir.Read(out long entriesRead3, SpanHelpers.AsSpan(ref entry3)).IsSuccess());
|
||||
Assert.True(dir.Read(out long entriesRead4, SpanHelpers.AsSpan(ref entry4)).IsSuccess());
|
||||
Assert.Success(dir.Read(out long entriesRead1, SpanHelpers.AsSpan(ref entry1)));
|
||||
Assert.Success(dir.Read(out long entriesRead2, SpanHelpers.AsSpan(ref entry2)));
|
||||
Assert.Success(dir.Read(out long entriesRead3, SpanHelpers.AsSpan(ref entry3)));
|
||||
Assert.Success(dir.Read(out long entriesRead4, SpanHelpers.AsSpan(ref entry4)));
|
||||
|
||||
Assert.Equal(1, entriesRead1);
|
||||
Assert.Equal(1, entriesRead2);
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.OpenFile(out IFile file, "/file".ToU8Span(), OpenMode.Read);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Read(out long bytesRead, 50, buffer, ReadOption.None).IsSuccess());
|
||||
Assert.Success(file.Read(out long bytesRead, 50, buffer, ReadOption.None));
|
||||
Assert.Equal(20, bytesRead);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Read(out _, 1, buffer, ReadOption.None);
|
||||
Assert.Equal(ResultFs.OutOfRange.Value, rc);
|
||||
Assert.Result(ResultFs.OutOfRange, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Read(out _, 0, buffer, ReadOption.None);
|
||||
Assert.Equal(ResultFs.InvalidOpenModeForRead.Value, rc);
|
||||
Assert.Result(ResultFs.InvalidOpenModeForRead, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Read(out _, -5, buffer, ReadOption.None);
|
||||
Assert.Equal(ResultFs.OutOfRange.Value, rc);
|
||||
Assert.Result(ResultFs.OutOfRange, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Read(out _, long.MaxValue - 5, buffer, ReadOption.None);
|
||||
Assert.Equal(ResultFs.OutOfRange.Value, rc);
|
||||
Assert.Result(ResultFs.OutOfRange, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.OpenFile(out IFile file, "/file".ToU8Span(), OpenMode.Read);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Read(out long bytesRead, 90, buffer, ReadOption.None).IsSuccess());
|
||||
Assert.Success(file.Read(out long bytesRead, 90, buffer, ReadOption.None));
|
||||
Assert.Equal(10, bytesRead);
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.OpenFile(out file, "/file".ToU8Span(), OpenMode.Read);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Read(out _, 90, buffer, ReadOption.None).IsSuccess());
|
||||
Assert.Success(file.Read(out _, 90, buffer, ReadOption.None));
|
||||
Assert.Equal(bufferExpected, buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
file.GetSize(out long fileSize);
|
||||
file.Dispose();
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(rc);
|
||||
Assert.Equal(54321, fileSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.OpenFile(out file, "/file".ToU8Span(), OpenMode.Read);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Read(out long bytesRead, 0, readData, ReadOption.None).IsSuccess());
|
||||
Assert.Success(file.Read(out long bytesRead, 0, readData, ReadOption.None));
|
||||
Assert.Equal(data.Length, bytesRead);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Write(5, buffer, WriteOption.None);
|
||||
Assert.Equal(ResultFs.FileExtensionWithoutOpenModeAllowAppend.Value, rc);
|
||||
Assert.Result(ResultFs.FileExtensionWithoutOpenModeAllowAppend, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Write(5, buffer, WriteOption.None);
|
||||
Assert.Equal(ResultFs.InvalidOpenModeForWrite.Value, rc);
|
||||
Assert.Result(ResultFs.InvalidOpenModeForWrite, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Write(-5, buffer, WriteOption.None);
|
||||
Assert.Equal(ResultFs.OutOfRange.Value, rc);
|
||||
Assert.Result(ResultFs.OutOfRange, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
using (file)
|
||||
{
|
||||
Result rc = file.Write(long.MaxValue - 5, buffer, WriteOption.None);
|
||||
Assert.Equal(ResultFs.OutOfRange.Value, rc);
|
||||
Assert.Result(ResultFs.OutOfRange, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.OpenFile(out IFile file, "/file".ToU8Span(), OpenMode.All);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Write(5, buffer, WriteOption.None).IsSuccess());
|
||||
Assert.Success(file.Write(5, buffer, WriteOption.None));
|
||||
|
||||
file.GetSize(out long newSize);
|
||||
Assert.Equal(15, newSize);
|
||||
|
@ -126,7 +126,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.OpenFile(out IFile file, "/file".ToU8Span(), OpenMode.All);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Write(15, buffer, WriteOption.None).IsSuccess());
|
||||
Assert.Success(file.Write(15, buffer, WriteOption.None));
|
||||
|
||||
file.GetSize(out long newSize);
|
||||
Assert.Equal(25, newSize);
|
||||
|
@ -149,7 +149,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.OpenFile(out IFile file, "/file".ToU8Span(), OpenMode.All);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Write(15, writeBuffer, WriteOption.None).IsSuccess());
|
||||
Assert.Success(file.Write(15, writeBuffer, WriteOption.None));
|
||||
|
||||
// Unwritten portions of new files are undefined, so write to the other portions
|
||||
file.Write(0, new byte[15], WriteOption.None);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.OpenDirectory(out _, "/file".ToU8Span(), OpenDirectoryMode.All);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.OpenFile(out _, "/dir".ToU8Span(), OpenMode.All);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,12 +18,12 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDir2 = fs.GetEntryType(out DirectoryEntryType dir2Type, "/dir2".ToU8Span());
|
||||
Result rcDir1 = fs.GetEntryType(out _, "/dir1".ToU8Span());
|
||||
|
||||
Assert.True(rcRename.IsSuccess());
|
||||
Assert.Success(rcRename);
|
||||
|
||||
Assert.True(rcDir2.IsSuccess());
|
||||
Assert.Success(rcDir2);
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir2Type);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcDir1);
|
||||
Assert.Result(ResultFs.PathNotFound, rcDir1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -47,19 +47,19 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDirCOld = fs.GetEntryType(out _, "/dir1/dirC".ToU8Span());
|
||||
Result rcFile1Old = fs.GetEntryType(out _, "/dir1/file1".ToU8Span());
|
||||
|
||||
Assert.True(rcRename.IsSuccess());
|
||||
Assert.Success(rcRename);
|
||||
|
||||
Assert.True(rcDir2.IsSuccess());
|
||||
Assert.True(rcDirC.IsSuccess());
|
||||
Assert.True(rcFile1.IsSuccess());
|
||||
Assert.Success(rcDir2);
|
||||
Assert.Success(rcDirC);
|
||||
Assert.Success(rcFile1);
|
||||
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir2Type);
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir1CType);
|
||||
Assert.Equal(DirectoryEntryType.File, file1Type);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcDir1);
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcDirCOld);
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcFile1Old);
|
||||
Assert.Result(ResultFs.PathNotFound, rcDir1);
|
||||
Assert.Result(ResultFs.PathNotFound, rcDirCOld);
|
||||
Assert.Result(ResultFs.PathNotFound, rcFile1Old);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -76,13 +76,13 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDir2 = fs.GetEntryType(out DirectoryEntryType dir2Type, "/parent2/dir2".ToU8Span());
|
||||
Result rcDir1 = fs.GetEntryType(out _, "/parent1/dir1".ToU8Span());
|
||||
|
||||
Assert.True(rcRename.IsSuccess());
|
||||
Assert.Success(rcRename);
|
||||
|
||||
Assert.Equal(Result.Success, rcDir2);
|
||||
Assert.True(rcDir2.IsSuccess());
|
||||
Assert.Success(rcDir2);
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir2Type);
|
||||
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rcDir1);
|
||||
Assert.Result(ResultFs.PathNotFound, rcDir1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -98,10 +98,10 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rcDir1 = fs.GetEntryType(out DirectoryEntryType dir1Type, "/dir1".ToU8Span());
|
||||
Result rcDir2 = fs.GetEntryType(out DirectoryEntryType dir2Type, "/dir2".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathAlreadyExists.Value, rcRename);
|
||||
Assert.Result(ResultFs.PathAlreadyExists, rcRename);
|
||||
|
||||
Assert.True(rcDir1.IsSuccess());
|
||||
Assert.True(rcDir2.IsSuccess());
|
||||
Assert.Success(rcDir1);
|
||||
Assert.Success(rcDir2);
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir1Type);
|
||||
Assert.Equal(DirectoryEntryType.Directory, dir2Type);
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
fs.CreateFile("/file1".ToU8Span(), 0, CreateFileOptions.None);
|
||||
|
||||
Assert.True(fs.RenameFile("/file1".ToU8Span(), "/file2".ToU8Span()).IsSuccess());
|
||||
Assert.Success(fs.RenameFile("/file1".ToU8Span(), "/file2".ToU8Span()));
|
||||
|
||||
Assert.True(fs.GetEntryType(out DirectoryEntryType type, "/file2".ToU8Span()).IsSuccess());
|
||||
Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "/file2".ToU8Span()));
|
||||
Result rc = fs.GetEntryType(out _, "/file1".ToU8Span());
|
||||
|
||||
Assert.Equal(DirectoryEntryType.File, type);
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
[Fact]
|
||||
public void RenameFile_DifferentParentDirectory_EntryIsRenamed()
|
||||
|
@ -30,13 +30,13 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
fs.CreateFile("/file1".ToU8Span(), 0, CreateFileOptions.None);
|
||||
fs.CreateDirectory("/dir".ToU8Span());
|
||||
|
||||
Assert.True(fs.RenameFile("/file1".ToU8Span(), "/dir/file2".ToU8Span()).IsSuccess());
|
||||
Assert.Success(fs.RenameFile("/file1".ToU8Span(), "/dir/file2".ToU8Span()));
|
||||
|
||||
Assert.True(fs.GetEntryType(out DirectoryEntryType type, "/dir/file2".ToU8Span()).IsSuccess());
|
||||
Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "/dir/file2".ToU8Span()));
|
||||
Result rc = fs.GetEntryType(out _, "/file1".ToU8Span());
|
||||
|
||||
Assert.Equal(DirectoryEntryType.File, type);
|
||||
Assert.Equal(ResultFs.PathNotFound.Value, rc);
|
||||
Assert.Result(ResultFs.PathNotFound, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -49,7 +49,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.RenameFile("/file1".ToU8Span(), "/file2".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathAlreadyExists.Value, rc);
|
||||
Assert.Result(ResultFs.PathAlreadyExists, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -62,7 +62,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
Result rc = fs.RenameFile("/file".ToU8Span(), "/dir".ToU8Span());
|
||||
|
||||
Assert.Equal(ResultFs.PathAlreadyExists.Value, rc);
|
||||
Assert.Result(ResultFs.PathAlreadyExists, rc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -75,14 +75,14 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
|
||||
fs.RenameFile("/file1".ToU8Span(), "/file2".ToU8Span());
|
||||
|
||||
Assert.True(fs.OpenFile(out IFile file1, "/file1".ToU8Span(), OpenMode.Read).IsSuccess());
|
||||
Assert.True(fs.OpenFile(out IFile file2, "/file2".ToU8Span(), OpenMode.Read).IsSuccess());
|
||||
Assert.Success(fs.OpenFile(out IFile file1, "/file1".ToU8Span(), OpenMode.Read));
|
||||
Assert.Success(fs.OpenFile(out IFile file2, "/file2".ToU8Span(), OpenMode.Read));
|
||||
|
||||
using (file1)
|
||||
using (file2)
|
||||
{
|
||||
Assert.True(file1.GetSize(out long file1Size).IsSuccess());
|
||||
Assert.True(file2.GetSize(out long file2Size).IsSuccess());
|
||||
Assert.Success(file1.GetSize(out long file1Size));
|
||||
Assert.Success(file2.GetSize(out long file2Size));
|
||||
|
||||
Assert.Equal(54321, file1Size);
|
||||
Assert.Equal(12345, file2Size);
|
||||
|
@ -110,7 +110,7 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|||
Result rc = file.Read(out long bytesRead, 0, readData, ReadOption.None);
|
||||
file.Dispose();
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(rc);
|
||||
Assert.Equal(data.Length, bytesRead);
|
||||
Assert.Equal(data, readData);
|
||||
}
|
||||
|
|
|
@ -30,9 +30,8 @@ namespace LibHac.Tests.Fs
|
|||
(IFileSystem baseFs, IFileSystem subDirFs) = CreateFileSystemInternal();
|
||||
|
||||
subDirFs.CreateFile("/file".ToU8Span(), 0, CreateFileOptions.None);
|
||||
Result rc = baseFs.GetEntryType(out DirectoryEntryType type, "/sub/path/file".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(baseFs.GetEntryType(out DirectoryEntryType type, "/sub/path/file".ToU8Span()));
|
||||
Assert.Equal(DirectoryEntryType.File, type);
|
||||
}
|
||||
|
||||
|
@ -42,9 +41,8 @@ namespace LibHac.Tests.Fs
|
|||
(IFileSystem baseFs, IFileSystem subDirFs) = CreateFileSystemInternal();
|
||||
|
||||
subDirFs.CreateDirectory("/dir".ToU8Span());
|
||||
Result rc = baseFs.GetEntryType(out DirectoryEntryType type, "/sub/path/dir".ToU8Span());
|
||||
|
||||
Assert.True(rc.IsSuccess());
|
||||
Assert.Success(baseFs.GetEntryType(out DirectoryEntryType type, "/sub/path/dir".ToU8Span()));
|
||||
Assert.Equal(DirectoryEntryType.Directory, type);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue