mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Update NUnit.
This commit is contained in:
@@ -42,7 +42,7 @@ public abstract class FsExtractHashIssueTest
|
||||
Dictionary<string, string> options = ParsedOptions;
|
||||
options["debug"] = Debug.ToString();
|
||||
|
||||
Assert.IsNotNull(inputFilter, Localization.Cannot_open_specified_file);
|
||||
Assert.That(inputFilter, Is.Not.Null, Localization.Cannot_open_specified_file);
|
||||
|
||||
Encoding encodingClass = null;
|
||||
|
||||
@@ -52,15 +52,17 @@ public abstract class FsExtractHashIssueTest
|
||||
|
||||
var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
|
||||
|
||||
Assert.NotNull(imageFormat, Localization.Image_format_not_identified_not_proceeding_with_analysis);
|
||||
Assert.That(imageFormat, Is.Not.Null, Localization.Image_format_not_identified_not_proceeding_with_analysis);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError, imageFormat.Open(inputFilter), Localization.Unable_to_open_image_format);
|
||||
Assert.That(imageFormat.Open(inputFilter),
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
Localization.Unable_to_open_image_format);
|
||||
|
||||
List<Partition> partitions = Core.Partitions.GetAll(imageFormat);
|
||||
|
||||
if(partitions.Count == 0)
|
||||
{
|
||||
Assert.IsFalse(ExpectPartitions, Localization.No_partitions_found);
|
||||
Assert.That(ExpectPartitions, Is.False, Localization.No_partitions_found);
|
||||
|
||||
partitions.Add(new Partition
|
||||
{
|
||||
@@ -75,7 +77,7 @@ public abstract class FsExtractHashIssueTest
|
||||
|
||||
var filesystemFound = false;
|
||||
|
||||
Assert.True(File.Exists($"{TestFile}.unittest.json"));
|
||||
Assert.That(File.Exists($"{TestFile}.unittest.json"));
|
||||
|
||||
var serializerOptions = new JsonSerializerOptions
|
||||
{
|
||||
@@ -93,13 +95,13 @@ public abstract class FsExtractHashIssueTest
|
||||
var sr = new FileStream($"{TestFile}.unittest.json", FileMode.Open);
|
||||
FsExtractHashData expectedData = JsonSerializer.Deserialize<FsExtractHashData>(sr, serializerOptions);
|
||||
|
||||
Assert.NotNull(expectedData);
|
||||
Assert.That(expectedData, Is.Not.Null);
|
||||
|
||||
Assert.AreEqual(expectedData.Partitions.Length,
|
||||
partitions.Count,
|
||||
string.Format(Localization.Excepted_0_partitions_but_found_1,
|
||||
expectedData.Partitions.Length,
|
||||
partitions.Count));
|
||||
Assert.That(partitions,
|
||||
Has.Count.EqualTo(expectedData.Partitions.Length),
|
||||
string.Format(Localization.Excepted_0_partitions_but_found_1,
|
||||
expectedData.Partitions.Length,
|
||||
partitions.Count));
|
||||
|
||||
for(var i = 0; i < partitions.Count; i++)
|
||||
{
|
||||
@@ -107,22 +109,23 @@ public abstract class FsExtractHashIssueTest
|
||||
|
||||
if(idPlugins.Count == 0)
|
||||
{
|
||||
Assert.IsNull(expectedData.Partitions[i],
|
||||
string.Format(Localization.Expected_no_filesystems_identified_in_partition_0_but_found_1,
|
||||
i,
|
||||
idPlugins.Count));
|
||||
Assert.That(expectedData.Partitions[i],
|
||||
Is.Null,
|
||||
string.Format(Localization.Expected_no_filesystems_identified_in_partition_0_but_found_1,
|
||||
i,
|
||||
idPlugins.Count));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(expectedData.Partitions[i].Volumes is null) continue;
|
||||
|
||||
Assert.AreEqual(expectedData.Partitions[i].Volumes.Length,
|
||||
idPlugins.Count,
|
||||
string.Format(Localization.Expected_0_filesystems_identified_in_partition_1_but_found_2,
|
||||
expectedData.Partitions[i].Volumes.Length,
|
||||
i,
|
||||
idPlugins.Count));
|
||||
Assert.That(idPlugins,
|
||||
Has.Count.EqualTo(expectedData.Partitions[i].Volumes.Length),
|
||||
string.Format(Localization.Expected_0_filesystems_identified_in_partition_1_but_found_2,
|
||||
expectedData.Partitions[i].Volumes.Length,
|
||||
i,
|
||||
idPlugins.Count));
|
||||
|
||||
for(var j = 0; j < idPlugins.Count; j++)
|
||||
{
|
||||
@@ -130,24 +133,26 @@ public abstract class FsExtractHashIssueTest
|
||||
|
||||
if(!plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out IReadOnlyFilesystem fs)) continue;
|
||||
|
||||
Assert.IsNotNull(fs, string.Format(Localization.Could_not_instantiate_filesystem_0, pluginName));
|
||||
Assert.That(fs,
|
||||
Is.Not.Null,
|
||||
string.Format(Localization.Could_not_instantiate_filesystem_0, pluginName));
|
||||
|
||||
filesystemFound = true;
|
||||
|
||||
ErrorNumber error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError,
|
||||
error,
|
||||
string.Format(Localization.Could_not_mount_0_in_partition_1, pluginName, i));
|
||||
Assert.That(error,
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
string.Format(Localization.Could_not_mount_0_in_partition_1, pluginName, i));
|
||||
|
||||
Assert.AreEqual(expectedData.Partitions[i].Volumes[j].VolumeName,
|
||||
fs.Metadata.VolumeName,
|
||||
string.Format(Localization
|
||||
.Excepted_volume_name_0_for_filesystem_1_in_partition_2_but_found_3,
|
||||
expectedData.Partitions[i].Volumes[j].VolumeName,
|
||||
j,
|
||||
i,
|
||||
fs.Metadata.VolumeName));
|
||||
Assert.That(fs.Metadata.VolumeName,
|
||||
Is.EqualTo(expectedData.Partitions[i].Volumes[j].VolumeName),
|
||||
string.Format(Localization
|
||||
.Excepted_volume_name_0_for_filesystem_1_in_partition_2_but_found_3,
|
||||
expectedData.Partitions[i].Volumes[j].VolumeName,
|
||||
j,
|
||||
i,
|
||||
fs.Metadata.VolumeName));
|
||||
|
||||
VolumeData volumeData = expectedData.Partitions[i].Volumes[j];
|
||||
|
||||
@@ -160,7 +165,7 @@ public abstract class FsExtractHashIssueTest
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsTrue(filesystemFound, Localization.No_filesystems_found);
|
||||
Assert.That(filesystemFound, Localization.No_filesystems_found);
|
||||
}
|
||||
|
||||
static void ExtractFilesInDir(string path, IReadOnlyFilesystem fs, bool doXattrs, VolumeData volumeData)
|
||||
@@ -169,30 +174,32 @@ public abstract class FsExtractHashIssueTest
|
||||
|
||||
ErrorNumber error = fs.OpenDir(path, out IDirNode node);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError,
|
||||
error,
|
||||
string.Format(Localization.Error_0_reading_root_directory, error.ToString()));
|
||||
Assert.That(error,
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
string.Format(Localization.Error_0_reading_root_directory, error.ToString()));
|
||||
|
||||
while(fs.ReadDir(node, out string entry) == ErrorNumber.NoError && entry is not null)
|
||||
{
|
||||
error = fs.Stat(path + "/" + entry, out FileEntryInfo stat);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError,
|
||||
error,
|
||||
string.Format(Localization.Error_getting_stat_for_entry_0, entry));
|
||||
Assert.That(error,
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
string.Format(Localization.Error_getting_stat_for_entry_0, entry));
|
||||
|
||||
if(stat.Attributes.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
Assert.True(volumeData.Directories.Contains(entry),
|
||||
Assert.That(volumeData.Directories,
|
||||
Does.Contain(entry),
|
||||
string.Format(Localization.Found_unexpected_directory_0, entry));
|
||||
|
||||
volumeData.Directories.Remove(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.True(volumeData.Directories.Contains(path + "/" + entry),
|
||||
Assert.That(volumeData.Directories,
|
||||
Does.Contain(path + "/" + entry),
|
||||
string.Format(Localization.Found_unexpected_directory_0, path + "/" + entry));
|
||||
|
||||
volumeData.Directories.Remove(path + "/" + entry);
|
||||
@@ -207,15 +214,15 @@ public abstract class FsExtractHashIssueTest
|
||||
|
||||
if(string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
Assert.IsTrue(volumeData.Files.TryGetValue(entry, out fileData),
|
||||
string.Format(Localization.Found_unexpected_file_0, entry));
|
||||
Assert.That(volumeData.Files.TryGetValue(entry, out fileData),
|
||||
string.Format(Localization.Found_unexpected_file_0, entry));
|
||||
|
||||
volumeData.Files.Remove(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsTrue(volumeData.Files.TryGetValue(path + "/" + entry, out fileData),
|
||||
string.Format(Localization.Found_unexpected_file_0, path + "/" + entry));
|
||||
Assert.That(volumeData.Files.TryGetValue(path + "/" + entry, out fileData),
|
||||
string.Format(Localization.Found_unexpected_file_0, path + "/" + entry));
|
||||
|
||||
volumeData.Files.Remove(path + "/" + entry);
|
||||
}
|
||||
@@ -224,11 +231,11 @@ public abstract class FsExtractHashIssueTest
|
||||
{
|
||||
error = fs.ListXAttr(path + "/" + entry, out List<string> xattrs);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError,
|
||||
error,
|
||||
string.Format(Localization.Error_0_getting_extended_attributes_for_entry_1,
|
||||
error,
|
||||
path + "/" + entry));
|
||||
Assert.That(error,
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
string.Format(Localization.Error_0_getting_extended_attributes_for_entry_1,
|
||||
error,
|
||||
path + "/" + entry));
|
||||
|
||||
Dictionary<string, string> expectedXattrs = fileData.XattrsWithMd5;
|
||||
|
||||
@@ -236,29 +243,29 @@ public abstract class FsExtractHashIssueTest
|
||||
{
|
||||
foreach(string xattr in xattrs)
|
||||
{
|
||||
Assert.IsTrue(expectedXattrs.TryGetValue(xattr, out string expectedXattrMd5),
|
||||
string.Format(Localization.Found_unexpected_extended_attribute_0_in_file_1,
|
||||
xattr,
|
||||
entry));
|
||||
Assert.That(expectedXattrs.TryGetValue(xattr, out string expectedXattrMd5),
|
||||
string.Format(Localization.Found_unexpected_extended_attribute_0_in_file_1,
|
||||
xattr,
|
||||
entry));
|
||||
|
||||
expectedXattrs.Remove(xattr);
|
||||
|
||||
byte[] xattrBuf = [];
|
||||
error = fs.GetXattr(path + "/" + entry, xattr, ref xattrBuf);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError,
|
||||
error,
|
||||
string.Format(Localization.Error_0_reading_extended_attributes_for_entry_1,
|
||||
error,
|
||||
path + "/" + entry));
|
||||
Assert.That(error,
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
string.Format(Localization.Error_0_reading_extended_attributes_for_entry_1,
|
||||
error,
|
||||
path + "/" + entry));
|
||||
|
||||
string xattrMd5 = Md5Context.Data(xattrBuf, out _);
|
||||
|
||||
Assert.AreEqual(expectedXattrMd5,
|
||||
xattrMd5,
|
||||
string.Format(Localization.Invalid_checksum_for_xattr_0_for_file_1,
|
||||
xattr,
|
||||
path + "/" + entry));
|
||||
Assert.That(xattrMd5,
|
||||
Is.EqualTo(expectedXattrMd5),
|
||||
string.Format(Localization.Invalid_checksum_for_xattr_0_for_file_1,
|
||||
xattr,
|
||||
path + "/" + entry));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,30 +278,27 @@ public abstract class FsExtractHashIssueTest
|
||||
var buffer = new byte[stat.Length];
|
||||
ErrorNumber ret = fs.OpenFile(path + "/" + entry, out IFileNode fileNode);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError,
|
||||
ret,
|
||||
string.Format(Localization.Error_0_reading_file_1, ret, path + "/" + entry));
|
||||
Assert.That(ret,
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
string.Format(Localization.Error_0_reading_file_1, ret, path + "/" + entry));
|
||||
|
||||
ret = fs.ReadFile(fileNode, stat.Length, buffer, out long readBytes);
|
||||
|
||||
Assert.AreEqual(ErrorNumber.NoError,
|
||||
ret,
|
||||
string.Format(Localization.Error_0_reading_file_1, ret, path + "/" + entry));
|
||||
Assert.That(ret,
|
||||
Is.EqualTo(ErrorNumber.NoError),
|
||||
string.Format(Localization.Error_0_reading_file_1, ret, path + "/" + entry));
|
||||
|
||||
Assert.AreEqual(stat.Length,
|
||||
readBytes,
|
||||
string.Format(Localization.Error_0_reading_file_1,
|
||||
readBytes,
|
||||
stat.Length,
|
||||
path + "/" + entry));
|
||||
Assert.That(readBytes,
|
||||
Is.EqualTo(stat.Length),
|
||||
string.Format(Localization.Error_0_reading_file_1, readBytes, stat.Length, path + "/" + entry));
|
||||
|
||||
fs.CloseFile(fileNode);
|
||||
|
||||
string calculatedMd5 = Md5Context.Data(buffer, out _);
|
||||
|
||||
Assert.AreEqual(fileData.Md5,
|
||||
calculatedMd5,
|
||||
string.Format(Localization.Invalid_checksum_for_file_0, path + "/" + entry));
|
||||
Assert.That(calculatedMd5,
|
||||
Is.EqualTo(fileData.Md5),
|
||||
string.Format(Localization.Invalid_checksum_for_file_0, path + "/" + entry));
|
||||
}
|
||||
|
||||
fs.CloseDir(node);
|
||||
|
||||
Reference in New Issue
Block a user