diff --git a/Aaru.Tests/Aaru.Tests.csproj b/Aaru.Tests/Aaru.Tests.csproj index e8fc2e841..99c4b4847 100644 --- a/Aaru.Tests/Aaru.Tests.csproj +++ b/Aaru.Tests/Aaru.Tests.csproj @@ -18,7 +18,11 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Aaru.Tests/Checksums/SHA512.cs b/Aaru.Tests/Checksums/SHA512.cs index 3dca51622..834f034dc 100644 --- a/Aaru.Tests/Checksums/SHA512.cs +++ b/Aaru.Tests/Checksums/SHA512.cs @@ -107,14 +107,14 @@ public class Sha512 fs.Close(); fs.Dispose(); Sha512Context.Data(data, out byte[] result); - Assert.AreEqual(_expectedRandom, result); + Assert.That(result, Is.EqualTo(_expectedRandom)); } [Test] public void RandomFile() { byte[] result = Sha512Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(_expectedRandom, result); + Assert.That(result, Is.EqualTo(_expectedRandom)); } [Test] @@ -132,6 +132,6 @@ public class Sha512 IChecksum ctx = new Sha512Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(_expectedRandom, result); + Assert.That(result, Is.EqualTo(_expectedRandom)); } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/SpamSum.cs b/Aaru.Tests/Checksums/SpamSum.cs index 2f4deb222..9a80d2516 100644 --- a/Aaru.Tests/Checksums/SpamSum.cs +++ b/Aaru.Tests/Checksums/SpamSum.cs @@ -53,7 +53,7 @@ public class SpamSum fs.Close(); fs.Dispose(); string result = SpamSumContext.Data(data, out _); - Assert.AreEqual(EXPECTED_EMPTY, result); + Assert.That(result, Is.EqualTo(EXPECTED_EMPTY)); } [Test] @@ -71,7 +71,7 @@ public class SpamSum IChecksum ctx = new SpamSumContext(); ctx.Update(data); string result = ctx.End(); - Assert.AreEqual(EXPECTED_EMPTY, result); + Assert.That(result, Is.EqualTo(EXPECTED_EMPTY)); } [Test] @@ -87,7 +87,7 @@ public class SpamSum fs.Close(); fs.Dispose(); string result = SpamSumContext.Data(data, out _); - Assert.AreEqual(EXPECTED_RANDOM, result); + Assert.That(result, Is.EqualTo(EXPECTED_RANDOM)); } [Test] @@ -105,6 +105,6 @@ public class SpamSum IChecksum ctx = new SpamSumContext(); ctx.Update(data); string result = ctx.End(); - Assert.AreEqual(EXPECTED_RANDOM, result); + Assert.That(result, Is.EqualTo(EXPECTED_RANDOM)); } } \ No newline at end of file diff --git a/Aaru.Tests/Devices/IomegaJaz.cs b/Aaru.Tests/Devices/IomegaJaz.cs index 4b39ab34c..d03f91d19 100644 --- a/Aaru.Tests/Devices/IomegaJaz.cs +++ b/Aaru.Tests/Devices/IomegaJaz.cs @@ -65,7 +65,7 @@ public class IomegaJaz var image = new ZZZRawImage(); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, _testFiles[i])); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, _testFiles[i])); if(opened != ErrorNumber.NoError) continue; @@ -73,17 +73,17 @@ public class IomegaJaz { Assert.Multiple(() => { - Assert.AreEqual(_sectors[i], - image.Info.Sectors, - string.Format(Localization.Sectors_0, _testFiles[i])); + Assert.That(image.Info.Sectors, + Is.EqualTo(_sectors[i]), + string.Format(Localization.Sectors_0, _testFiles[i])); - Assert.AreEqual(_sectorSize[i], - image.Info.SectorSize, - string.Format(Localization.Sector_size_0, _testFiles[i])); + Assert.That(image.Info.SectorSize, + Is.EqualTo(_sectorSize[i]), + string.Format(Localization.Sector_size_0, _testFiles[i])); - Assert.AreEqual(_mediaTypes[i], - image.Info.MediaType, - string.Format(Localization.Media_type_0, _testFiles[i])); + Assert.That(image.Info.MediaType, + Is.EqualTo(_mediaTypes[i]), + string.Format(Localization.Media_type_0, _testFiles[i])); }); } } diff --git a/Aaru.Tests/Devices/LS120.cs b/Aaru.Tests/Devices/LS120.cs index c7c8ec7f7..8d38b2f70 100644 --- a/Aaru.Tests/Devices/LS120.cs +++ b/Aaru.Tests/Devices/LS120.cs @@ -65,7 +65,7 @@ public class Ls120 var image = new ZZZRawImage(); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, _testFiles[i])); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, _testFiles[i])); if(opened != ErrorNumber.NoError) continue; @@ -73,17 +73,17 @@ public class Ls120 { Assert.Multiple(() => { - Assert.AreEqual(_sectors[i], - image.Info.Sectors, - string.Format(Localization.Sectors_0, _testFiles[i])); + Assert.That(image.Info.Sectors, + Is.EqualTo(_sectors[i]), + string.Format(Localization.Sectors_0, _testFiles[i])); - Assert.AreEqual(_sectorSize[i], - image.Info.SectorSize, - string.Format(Localization.Sector_size_0, _testFiles[i])); + Assert.That(image.Info.SectorSize, + Is.EqualTo(_sectorSize[i]), + string.Format(Localization.Sector_size_0, _testFiles[i])); - Assert.AreEqual(_mediaTypes[i], - image.Info.MediaType, - string.Format(Localization.Media_type_0, _testFiles[i])); + Assert.That(image.Info.MediaType, + Is.EqualTo(_mediaTypes[i]), + string.Format(Localization.Media_type_0, _testFiles[i])); }); } } diff --git a/Aaru.Tests/Devices/MultiMediaCard/CID.cs b/Aaru.Tests/Devices/MultiMediaCard/CID.cs index ac793ec63..24906b814 100644 --- a/Aaru.Tests/Devices/MultiMediaCard/CID.cs +++ b/Aaru.Tests/Devices/MultiMediaCard/CID.cs @@ -40,33 +40,35 @@ public class CID Assert.Multiple(() => { int count = Marshal.ConvertFromHexAscii(cids[i], out byte[] response); - Assert.AreEqual(16, count, string.Format(Localization.Size_0, cards[i])); + Assert.That(count, Is.EqualTo(16), string.Format(Localization.Size_0, cards[i])); Decoders.MMC.CID cid = Decoders.MMC.Decoders.DecodeCID(response); - Assert.IsNotNull(cid, string.Format(Localization.Decoded_0, cards[i])); + Assert.That(cid, Is.Not.Null, string.Format(Localization.Decoded_0, cards[i])); - Assert.AreEqual(manufacturers[i], - cid.Manufacturer, - string.Format(Localization.Manufacturer_0, cards[i])); + Assert.That(cid.Manufacturer, + Is.EqualTo(manufacturers[i]), + string.Format(Localization.Manufacturer_0, cards[i])); - Assert.AreEqual(applications[i], - cid.ApplicationID, - string.Format(Localization.Application_ID_0, cards[i])); + Assert.That(cid.ApplicationID, + Is.EqualTo(applications[i]), + string.Format(Localization.Application_ID_0, cards[i])); - Assert.AreEqual(names[i], cid.ProductName, string.Format(Localization.Product_name_0, cards[i])); + Assert.That(cid.ProductName, + Is.EqualTo(names[i]), + string.Format(Localization.Product_name_0, cards[i])); - Assert.AreEqual(revisions[i], - cid.ProductRevision, - string.Format(Localization.Product_revision_0, cards[i])); + Assert.That(cid.ProductRevision, + Is.EqualTo(revisions[i]), + string.Format(Localization.Product_revision_0, cards[i])); - Assert.AreEqual(serials[i], - cid.ProductSerialNumber, - string.Format(Localization.Serial_number_0, cards[i])); + Assert.That(cid.ProductSerialNumber, + Is.EqualTo(serials[i]), + string.Format(Localization.Serial_number_0, cards[i])); - Assert.AreEqual(dates[i], - cid.ManufacturingDate, - string.Format(Localization.Manufacturing_date_0, cards[i])); + Assert.That(cid.ManufacturingDate, + Is.EqualTo(dates[i]), + string.Format(Localization.Manufacturing_date_0, cards[i])); - Assert.AreEqual(crcs[i], cid.CRC, string.Format(Localization.CRC_0, cards[i])); + Assert.That(cid.CRC, Is.EqualTo(crcs[i]), string.Format(Localization.CRC_0, cards[i])); }); } } diff --git a/Aaru.Tests/Devices/MultiMediaCard/CSD.cs b/Aaru.Tests/Devices/MultiMediaCard/CSD.cs index 9c0e5f856..01cd07708 100644 --- a/Aaru.Tests/Devices/MultiMediaCard/CSD.cs +++ b/Aaru.Tests/Devices/MultiMediaCard/CSD.cs @@ -90,116 +90,120 @@ public class CSD Assert.Multiple(() => { int count = Marshal.ConvertFromHexAscii(csds[i], out byte[] response); - Assert.AreEqual(16, count, string.Format(Localization.Size_0, cards[i])); + Assert.That(count, Is.EqualTo(16), string.Format(Localization.Size_0, cards[i])); Decoders.MMC.CSD csd = Decoders.MMC.Decoders.DecodeCSD(response); - Assert.IsNotNull(csd, string.Format(Localization.Decoded_0, cards[i])); + Assert.That(csd, Is.Not.Null, string.Format(Localization.Decoded_0, cards[i])); - Assert.AreEqual(structure_versions[i], - csd.Structure, - string.Format(Localization.Structure_version_0, cards[i])); + Assert.That(csd.Structure, + Is.EqualTo(structure_versions[i]), + string.Format(Localization.Structure_version_0, cards[i])); - Assert.AreEqual(spec_versions[i], - csd.Version, - string.Format(Localization.Specification_version_0, cards[i])); + Assert.That(csd.Version, + Is.EqualTo(spec_versions[i]), + string.Format(Localization.Specification_version_0, cards[i])); - Assert.AreEqual(taacs[i], csd.TAAC, string.Format(Localization.TAAC_0, cards[i])); - Assert.AreEqual(nsacs[i], csd.NSAC, string.Format(Localization.NSAC_0, cards[i])); - Assert.AreEqual(speeds[i], csd.Speed, string.Format(Localization.Transfer_speed_0, cards[i])); - Assert.AreEqual(classes[i], csd.Classes, string.Format(Localization.Classes_0, cards[i])); + Assert.That(csd.TAAC, Is.EqualTo(taacs[i]), string.Format(Localization.TAAC_0, cards[i])); + Assert.That(csd.NSAC, Is.EqualTo(nsacs[i]), string.Format(Localization.NSAC_0, cards[i])); - Assert.AreEqual(read_block_lengths[i], - csd.ReadBlockLength, - string.Format(Localization.Read_block_length_0, cards[i])); + Assert.That(csd.Speed, + Is.EqualTo(speeds[i]), + string.Format(Localization.Transfer_speed_0, cards[i])); - Assert.AreEqual(read_partial_blocks[i], - csd.ReadsPartialBlocks, - string.Format(Localization.Reads_partial_blocks_0, cards[i])); + Assert.That(csd.Classes, Is.EqualTo(classes[i]), string.Format(Localization.Classes_0, cards[i])); - Assert.AreEqual(write_misaligned_block[i], - csd.WriteMisalignment, - string.Format(Localization.Writes_misaligned_blocks_0, cards[i])); + Assert.That(csd.ReadBlockLength, + Is.EqualTo(read_block_lengths[i]), + string.Format(Localization.Read_block_length_0, cards[i])); - Assert.AreEqual(read_misaligned_block[i], - csd.ReadMisalignment, - string.Format(Localization.Reads_misaligned_blocks_0, cards[i])); + Assert.That(csd.ReadsPartialBlocks, + Is.EqualTo(read_partial_blocks[i]), + string.Format(Localization.Reads_partial_blocks_0, cards[i])); - Assert.AreEqual(dsr_implemented[i], - csd.DSRImplemented, - string.Format(Localization.DSR_implemented_0, cards[i])); + Assert.That(csd.WriteMisalignment, + Is.EqualTo(write_misaligned_block[i]), + string.Format(Localization.Writes_misaligned_blocks_0, cards[i])); - Assert.AreEqual(card_sizes[i], csd.Size, string.Format(Localization.Card_size_0, cards[i])); + Assert.That(csd.ReadMisalignment, + Is.EqualTo(read_misaligned_block[i]), + string.Format(Localization.Reads_misaligned_blocks_0, cards[i])); - Assert.AreEqual(min_read_current[i], - csd.ReadCurrentAtVddMin, - string.Format(Localization.Reading_current_at_minimum_Vdd_0, cards[i])); + Assert.That(csd.DSRImplemented, + Is.EqualTo(dsr_implemented[i]), + string.Format(Localization.DSR_implemented_0, cards[i])); - Assert.AreEqual(max_read_current[i], - csd.ReadCurrentAtVddMax, - string.Format(Localization.Reading_current_at_maximum_Vdd_0, cards[i])); + Assert.That(csd.Size, Is.EqualTo(card_sizes[i]), string.Format(Localization.Card_size_0, cards[i])); - Assert.AreEqual(min_write_current[i], - csd.WriteCurrentAtVddMin, - string.Format(Localization.Writing_current_at_minimum_Vdd_0, cards[i])); + Assert.That(csd.ReadCurrentAtVddMin, + Is.EqualTo(min_read_current[i]), + string.Format(Localization.Reading_current_at_minimum_Vdd_0, cards[i])); - Assert.AreEqual(max_write_current[i], - csd.WriteCurrentAtVddMax, - string.Format(Localization.Writing_current_at_maximum_Vdd_0, cards[i])); + Assert.That(csd.ReadCurrentAtVddMax, + Is.EqualTo(max_read_current[i]), + string.Format(Localization.Reading_current_at_maximum_Vdd_0, cards[i])); - Assert.AreEqual(size_multiplier[i], - csd.SizeMultiplier, - string.Format(Localization.Card_size_multiplier_0, cards[i])); + Assert.That(csd.WriteCurrentAtVddMin, + Is.EqualTo(min_write_current[i]), + string.Format(Localization.Writing_current_at_minimum_Vdd_0, cards[i])); - Assert.AreEqual(sector_sizes[i], - csd.EraseGroupSize, - string.Format(Localization.Erase_sector_size_0, cards[i])); + Assert.That(csd.WriteCurrentAtVddMax, + Is.EqualTo(max_write_current[i]), + string.Format(Localization.Writing_current_at_maximum_Vdd_0, cards[i])); - Assert.AreEqual(erase_sector_sizes[i], - csd.EraseGroupSizeMultiplier, - string.Format(Localization.Erase_group_size_0, cards[i])); + Assert.That(csd.SizeMultiplier, + Is.EqualTo(size_multiplier[i]), + string.Format(Localization.Card_size_multiplier_0, cards[i])); - Assert.AreEqual(write_protect_group_size[i], - csd.WriteProtectGroupSize, - string.Format(Localization.Write_protect_group_size_0, cards[i])); + Assert.That(csd.EraseGroupSize, + Is.EqualTo(sector_sizes[i]), + string.Format(Localization.Erase_sector_size_0, cards[i])); - Assert.AreEqual(write_protect_group_enable[i], - csd.WriteProtectGroupEnable, - string.Format(Localization.Write_protect_group_enable_0, cards[i])); + Assert.That(csd.EraseGroupSizeMultiplier, + Is.EqualTo(erase_sector_sizes[i]), + string.Format(Localization.Erase_group_size_0, cards[i])); - Assert.AreEqual(default_eccs[i], - csd.DefaultECC, - string.Format(Localization.Default_ECC_0, cards[i])); + Assert.That(csd.WriteProtectGroupSize, + Is.EqualTo(write_protect_group_size[i]), + string.Format(Localization.Write_protect_group_size_0, cards[i])); - Assert.AreEqual(r2w_factors[i], - csd.WriteSpeedFactor, - string.Format(Localization.Read_to_write_factor_0, cards[i])); + Assert.That(csd.WriteProtectGroupEnable, + Is.EqualTo(write_protect_group_enable[i]), + string.Format(Localization.Write_protect_group_enable_0, cards[i])); - Assert.AreEqual(write_block_lengths[i], - csd.WriteBlockLength, - string.Format(Localization.write_block_length_0, cards[i])); + Assert.That(csd.DefaultECC, + Is.EqualTo(default_eccs[i]), + string.Format(Localization.Default_ECC_0, cards[i])); - Assert.AreEqual(write_partial_blocks[i], - csd.WritesPartialBlocks, - string.Format(Localization.Writes_partial_blocks_0, cards[i])); + Assert.That(csd.WriteSpeedFactor, + Is.EqualTo(r2w_factors[i]), + string.Format(Localization.Read_to_write_factor_0, cards[i])); - Assert.AreEqual(file_format_group[i], - csd.FileFormatGroup, - string.Format(Localization.File_format_group_0, cards[i])); + Assert.That(csd.WriteBlockLength, + Is.EqualTo(write_block_lengths[i]), + string.Format(Localization.write_block_length_0, cards[i])); - Assert.AreEqual(copy[i], csd.Copy, string.Format(Localization.Copy_0, cards[i])); + Assert.That(csd.WritesPartialBlocks, + Is.EqualTo(write_partial_blocks[i]), + string.Format(Localization.Writes_partial_blocks_0, cards[i])); - Assert.AreEqual(permanent_write_protect[i], - csd.PermanentWriteProtect, - string.Format(Localization.Permanent_write_protect_0, cards[i])); + Assert.That(csd.FileFormatGroup, + Is.EqualTo(file_format_group[i]), + string.Format(Localization.File_format_group_0, cards[i])); - Assert.AreEqual(temporary_write_protect[i], - csd.TemporaryWriteProtect, - string.Format(Localization.Temporary_write_protect_0, cards[i])); + Assert.That(csd.Copy, Is.EqualTo(copy[i]), string.Format(Localization.Copy_0, cards[i])); - Assert.AreEqual(file_format[i], - csd.FileFormat, - string.Format(Localization.File_format_0, cards[i])); + Assert.That(csd.PermanentWriteProtect, + Is.EqualTo(permanent_write_protect[i]), + string.Format(Localization.Permanent_write_protect_0, cards[i])); - Assert.AreEqual(ecc[i], csd.ECC, string.Format(Localization.ECC_0, cards[i])); + Assert.That(csd.TemporaryWriteProtect, + Is.EqualTo(temporary_write_protect[i]), + string.Format(Localization.Temporary_write_protect_0, cards[i])); + + Assert.That(csd.FileFormat, + Is.EqualTo(file_format[i]), + string.Format(Localization.File_format_0, cards[i])); + + Assert.That(csd.ECC, Is.EqualTo(ecc[i]), string.Format(Localization.ECC_0, cards[i])); }); } } diff --git a/Aaru.Tests/Devices/MultiMediaCard/ExtendedCSD.cs b/Aaru.Tests/Devices/MultiMediaCard/ExtendedCSD.cs index 41b826c25..f916da953 100644 --- a/Aaru.Tests/Devices/MultiMediaCard/ExtendedCSD.cs +++ b/Aaru.Tests/Devices/MultiMediaCard/ExtendedCSD.cs @@ -213,7 +213,7 @@ public class ExtendedCSD for(var i = 0; i < _ecsd.Length; i++) { Decoders.MMC.ExtendedCSD csd = Decoders.MMC.Decoders.DecodeExtendedCSD(_ecsd[i]); - Assert.IsNotNull(csd, string.Format(Localization.Not_decoded_0, i)); + Assert.That(csd, Is.Not.Null, string.Format(Localization.Not_decoded_0, i)); csd.Should().BeEquivalentTo(_decoded[i]); } } diff --git a/Aaru.Tests/Devices/PocketZip.cs b/Aaru.Tests/Devices/PocketZip.cs index 84d0ad69b..03cfdea98 100644 --- a/Aaru.Tests/Devices/PocketZip.cs +++ b/Aaru.Tests/Devices/PocketZip.cs @@ -65,7 +65,7 @@ public class PocketZip var image = new ZZZRawImage(); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, _testFiles[i])); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, _testFiles[i])); if(opened != ErrorNumber.NoError) continue; @@ -73,17 +73,17 @@ public class PocketZip { Assert.Multiple(() => { - Assert.AreEqual(_sectors[i], - image.Info.Sectors, - string.Format(Localization.Sectors_0, _testFiles[i])); + Assert.That(image.Info.Sectors, + Is.EqualTo(_sectors[i]), + string.Format(Localization.Sectors_0, _testFiles[i])); - Assert.AreEqual(_sectorSize[i], - image.Info.SectorSize, - string.Format(Localization.Sector_size_0, _testFiles[i])); + Assert.That(image.Info.SectorSize, + Is.EqualTo(_sectorSize[i]), + string.Format(Localization.Sector_size_0, _testFiles[i])); - Assert.AreEqual(_mediaTypes[i], - image.Info.MediaType, - string.Format(Localization.Media_type_0, _testFiles[i])); + Assert.That(image.Info.MediaType, + Is.EqualTo(_mediaTypes[i]), + string.Format(Localization.Media_type_0, _testFiles[i])); }); } } diff --git a/Aaru.Tests/Devices/SecureDigital/CID.cs b/Aaru.Tests/Devices/SecureDigital/CID.cs index 44c30215c..621072912 100644 --- a/Aaru.Tests/Devices/SecureDigital/CID.cs +++ b/Aaru.Tests/Devices/SecureDigital/CID.cs @@ -65,33 +65,35 @@ public class CID Assert.Multiple(() => { int count = Marshal.ConvertFromHexAscii(cids[i], out byte[] response); - Assert.AreEqual(16, count, string.Format(Localization.Size_0, cards[i])); + Assert.That(count, Is.EqualTo(16), string.Format(Localization.Size_0, cards[i])); Decoders.SecureDigital.CID cid = Decoders.SecureDigital.Decoders.DecodeCID(response); - Assert.IsNotNull(cid, string.Format(Localization.Decoded_0, cards[i])); + Assert.That(cid, Is.Not.Null, string.Format(Localization.Decoded_0, cards[i])); - Assert.AreEqual(manufacturers[i], - cid.Manufacturer, - string.Format(Localization.Manufacturer_0, cards[i])); + Assert.That(cid.Manufacturer, + Is.EqualTo(manufacturers[i]), + string.Format(Localization.Manufacturer_0, cards[i])); - Assert.AreEqual(applications[i], - cid.ApplicationID, - string.Format(Localization.Application_ID_0, cards[i])); + Assert.That(cid.ApplicationID, + Is.EqualTo(applications[i]), + string.Format(Localization.Application_ID_0, cards[i])); - Assert.AreEqual(names[i], cid.ProductName, string.Format(Localization.Product_name_0, cards[i])); + Assert.That(cid.ProductName, + Is.EqualTo(names[i]), + string.Format(Localization.Product_name_0, cards[i])); - Assert.AreEqual(revisions[i], - cid.ProductRevision, - string.Format(Localization.Product_revision_0, cards[i])); + Assert.That(cid.ProductRevision, + Is.EqualTo(revisions[i]), + string.Format(Localization.Product_revision_0, cards[i])); - Assert.AreEqual(serials[i], - cid.ProductSerialNumber, - string.Format(Localization.Serial_number_0, cards[i])); + Assert.That(cid.ProductSerialNumber, + Is.EqualTo(serials[i]), + string.Format(Localization.Serial_number_0, cards[i])); - Assert.AreEqual(dates[i], - cid.ManufacturingDate, - string.Format(Localization.Manufacturing_date_0, cards[i])); + Assert.That(cid.ManufacturingDate, + Is.EqualTo(dates[i]), + string.Format(Localization.Manufacturing_date_0, cards[i])); - Assert.AreEqual(crcs[i], cid.CRC, string.Format(Localization.CRC_0, cards[i])); + Assert.That(cid.CRC, Is.EqualTo(crcs[i]), string.Format(Localization.CRC_0, cards[i])); }); } } diff --git a/Aaru.Tests/Devices/SecureDigital/CSD.cs b/Aaru.Tests/Devices/SecureDigital/CSD.cs index eb6b2c996..c113182ec 100644 --- a/Aaru.Tests/Devices/SecureDigital/CSD.cs +++ b/Aaru.Tests/Devices/SecureDigital/CSD.cs @@ -124,98 +124,102 @@ public class CSD Assert.Multiple(() => { int count = Marshal.ConvertFromHexAscii(csds[i], out byte[] response); - Assert.AreEqual(16, count, string.Format(Localization.Size_0, cards[i])); + Assert.That(count, Is.EqualTo(16), string.Format(Localization.Size_0, cards[i])); Decoders.SecureDigital.CSD csd = Decoders.SecureDigital.Decoders.DecodeCSD(response); - Assert.IsNotNull(csd, string.Format(Localization.Decoded_0, cards[i])); + Assert.That(csd, Is.Not.Null, string.Format(Localization.Decoded_0, cards[i])); - Assert.AreEqual(structure_versions[i], - csd.Structure, - string.Format(Localization.Version_0, cards[i])); + Assert.That(csd.Structure, + Is.EqualTo(structure_versions[i]), + string.Format(Localization.Version_0, cards[i])); - Assert.AreEqual(taacs[i], csd.TAAC, string.Format(Localization.TAAC_0, cards[i])); - Assert.AreEqual(nsacs[i], csd.NSAC, string.Format(Localization.NSAC_0, cards[i])); - Assert.AreEqual(speeds[i], csd.Speed, string.Format(Localization.Transfer_speed_0, cards[i])); - Assert.AreEqual(classes[i], csd.Classes, string.Format(Localization.Classes_0, cards[i])); + Assert.That(csd.TAAC, Is.EqualTo(taacs[i]), string.Format(Localization.TAAC_0, cards[i])); + Assert.That(csd.NSAC, Is.EqualTo(nsacs[i]), string.Format(Localization.NSAC_0, cards[i])); - Assert.AreEqual(read_block_lengths[i], - csd.ReadBlockLength, - string.Format(Localization.Read_block_length_0, cards[i])); + Assert.That(csd.Speed, + Is.EqualTo(speeds[i]), + string.Format(Localization.Transfer_speed_0, cards[i])); - Assert.AreEqual(read_partial_blocks[i], - csd.ReadsPartialBlocks, - string.Format(Localization.Reads_partial_blocks_0, cards[i])); + Assert.That(csd.Classes, Is.EqualTo(classes[i]), string.Format(Localization.Classes_0, cards[i])); - Assert.AreEqual(write_misaligned_block[i], - csd.WriteMisalignment, - string.Format(Localization.Writes_misaligned_blocks_0, cards[i])); + Assert.That(csd.ReadBlockLength, + Is.EqualTo(read_block_lengths[i]), + string.Format(Localization.Read_block_length_0, cards[i])); - Assert.AreEqual(read_misaligned_block[i], - csd.ReadMisalignment, - string.Format(Localization.Reads_misaligned_blocks_0, cards[i])); + Assert.That(csd.ReadsPartialBlocks, + Is.EqualTo(read_partial_blocks[i]), + string.Format(Localization.Reads_partial_blocks_0, cards[i])); - Assert.AreEqual(dsr_implemented[i], - csd.DSRImplemented, - string.Format(Localization.DSR_implemented_0, cards[i])); + Assert.That(csd.WriteMisalignment, + Is.EqualTo(write_misaligned_block[i]), + string.Format(Localization.Writes_misaligned_blocks_0, cards[i])); - Assert.AreEqual(card_sizes[i], csd.Size, string.Format(Localization.Card_size_0, cards[i])); + Assert.That(csd.ReadMisalignment, + Is.EqualTo(read_misaligned_block[i]), + string.Format(Localization.Reads_misaligned_blocks_0, cards[i])); - Assert.AreEqual(min_read_current[i], - csd.ReadCurrentAtVddMin, - string.Format(Localization.Reading_current_at_minimum_Vdd_0, cards[i])); + Assert.That(csd.DSRImplemented, + Is.EqualTo(dsr_implemented[i]), + string.Format(Localization.DSR_implemented_0, cards[i])); - Assert.AreEqual(max_read_current[i], - csd.ReadCurrentAtVddMax, - string.Format(Localization.Reading_current_at_maximum_Vdd_0, cards[i])); + Assert.That(csd.Size, Is.EqualTo(card_sizes[i]), string.Format(Localization.Card_size_0, cards[i])); - Assert.AreEqual(min_write_current[i], - csd.WriteCurrentAtVddMin, - string.Format(Localization.Writing_current_at_minimum_Vdd_0, cards[i])); + Assert.That(csd.ReadCurrentAtVddMin, + Is.EqualTo(min_read_current[i]), + string.Format(Localization.Reading_current_at_minimum_Vdd_0, cards[i])); - Assert.AreEqual(max_write_current[i], - csd.WriteCurrentAtVddMax, - string.Format(Localization.Writing_current_at_maximum_Vdd_0, cards[i])); + Assert.That(csd.ReadCurrentAtVddMax, + Is.EqualTo(max_read_current[i]), + string.Format(Localization.Reading_current_at_maximum_Vdd_0, cards[i])); - Assert.AreEqual(size_multiplier[i], - csd.SizeMultiplier, - string.Format(Localization.Card_size_multiplier_0, cards[i])); + Assert.That(csd.WriteCurrentAtVddMin, + Is.EqualTo(min_write_current[i]), + string.Format(Localization.Writing_current_at_minimum_Vdd_0, cards[i])); - Assert.AreEqual(erase_block_enable[i], - csd.EraseBlockEnable, - string.Format(Localization.Erase_block_enable_0, cards[i])); + Assert.That(csd.WriteCurrentAtVddMax, + Is.EqualTo(max_write_current[i]), + string.Format(Localization.Writing_current_at_maximum_Vdd_0, cards[i])); - Assert.AreEqual(erase_sector_sizes[i], - csd.EraseSectorSize, - string.Format(Localization.Erase_sector_size_0, cards[i])); + Assert.That(csd.SizeMultiplier, + Is.EqualTo(size_multiplier[i]), + string.Format(Localization.Card_size_multiplier_0, cards[i])); - Assert.AreEqual(write_protect_group_size[i], - csd.WriteProtectGroupSize, - string.Format(Localization.Write_protect_group_size_0, cards[i])); + Assert.That(csd.EraseBlockEnable, + Is.EqualTo(erase_block_enable[i]), + string.Format(Localization.Erase_block_enable_0, cards[i])); - Assert.AreEqual(write_protect_group_enable[i], - csd.WriteProtectGroupEnable, - string.Format(Localization.Write_protect_group_enable_0, cards[i])); + Assert.That(csd.EraseSectorSize, + Is.EqualTo(erase_sector_sizes[i]), + string.Format(Localization.Erase_sector_size_0, cards[i])); - Assert.AreEqual(r2w_factors[i], - csd.WriteSpeedFactor, - string.Format(Localization.Read_to_write_factor_0, cards[i])); + Assert.That(csd.WriteProtectGroupSize, + Is.EqualTo(write_protect_group_size[i]), + string.Format(Localization.Write_protect_group_size_0, cards[i])); - Assert.AreEqual(file_format_group[i], - csd.FileFormatGroup, - string.Format(Localization.File_format_group_0, cards[i])); + Assert.That(csd.WriteProtectGroupEnable, + Is.EqualTo(write_protect_group_enable[i]), + string.Format(Localization.Write_protect_group_enable_0, cards[i])); - Assert.AreEqual(copy[i], csd.Copy, string.Format(Localization.Copy_0, cards[i])); + Assert.That(csd.WriteSpeedFactor, + Is.EqualTo(r2w_factors[i]), + string.Format(Localization.Read_to_write_factor_0, cards[i])); - Assert.AreEqual(permanent_write_protect[i], - csd.PermanentWriteProtect, - string.Format(Localization.Permanent_write_protect_0, cards[i])); + Assert.That(csd.FileFormatGroup, + Is.EqualTo(file_format_group[i]), + string.Format(Localization.File_format_group_0, cards[i])); - Assert.AreEqual(temporary_write_protect[i], - csd.TemporaryWriteProtect, - string.Format(Localization.Temporary_write_protect_0, cards[i])); + Assert.That(csd.Copy, Is.EqualTo(copy[i]), string.Format(Localization.Copy_0, cards[i])); - Assert.AreEqual(file_format[i], - csd.FileFormat, - string.Format(Localization.File_format_0, cards[i])); + Assert.That(csd.PermanentWriteProtect, + Is.EqualTo(permanent_write_protect[i]), + string.Format(Localization.Permanent_write_protect_0, cards[i])); + + Assert.That(csd.TemporaryWriteProtect, + Is.EqualTo(temporary_write_protect[i]), + string.Format(Localization.Temporary_write_protect_0, cards[i])); + + Assert.That(csd.FileFormat, + Is.EqualTo(file_format[i]), + string.Format(Localization.File_format_0, cards[i])); }); } } diff --git a/Aaru.Tests/Devices/SecureDigital/SCR.cs b/Aaru.Tests/Devices/SecureDigital/SCR.cs index 73157c414..775c089ff 100644 --- a/Aaru.Tests/Devices/SecureDigital/SCR.cs +++ b/Aaru.Tests/Devices/SecureDigital/SCR.cs @@ -71,44 +71,46 @@ public class SCR Assert.Multiple(() => { int count = Marshal.ConvertFromHexAscii(scrs[i], out byte[] response); - Assert.AreEqual(8, count, string.Format(Localization.Size_0, cards[i])); + Assert.That(count, Is.EqualTo(8), string.Format(Localization.Size_0, cards[i])); Decoders.SecureDigital.SCR scr = Decoders.SecureDigital.Decoders.DecodeSCR(response); - Assert.IsNotNull(scr, string.Format(Localization.Decoded_0, cards[i])); + Assert.That(scr, Is.Not.Null, string.Format(Localization.Decoded_0, cards[i])); - Assert.AreEqual(structure_version[i], - scr.Structure, - string.Format(Localization.Version_0, cards[i])); + Assert.That(scr.Structure, + Is.EqualTo(structure_version[i]), + string.Format(Localization.Version_0, cards[i])); - Assert.AreEqual(specification_version[i], - scr.Spec, - string.Format(Localization.Specification_version_0, cards[i])); + Assert.That(scr.Spec, + Is.EqualTo(specification_version[i]), + string.Format(Localization.Specification_version_0, cards[i])); - Assert.AreEqual(data_stat_after_erase[i], - scr.DataStatusAfterErase, - string.Format(Localization.Data_stat_after_erase_0, cards[i])); + Assert.That(scr.DataStatusAfterErase, + Is.EqualTo(data_stat_after_erase[i]), + string.Format(Localization.Data_stat_after_erase_0, cards[i])); - Assert.AreEqual(sd_security[i], scr.Security, string.Format(Localization.Security_0, cards[i])); + Assert.That(scr.Security, + Is.EqualTo(sd_security[i]), + string.Format(Localization.Security_0, cards[i])); - Assert.AreEqual((BusWidth)sd_bus_widths[i], - scr.BusWidth, - string.Format(Localization.Bus_widths_0, cards[i])); + Assert.That(scr.BusWidth, + Is.EqualTo((BusWidth)sd_bus_widths[i]), + string.Format(Localization.Bus_widths_0, cards[i])); - Assert.AreEqual(sd_spec3[i], scr.Spec3, string.Format(Localization.Spec_3_0, cards[i])); + Assert.That(scr.Spec3, Is.EqualTo(sd_spec3[i]), string.Format(Localization.Spec_3_0, cards[i])); - Assert.AreEqual(ex_security[i], - scr.ExtendedSecurity, - string.Format(Localization.Extended_security_0, cards[i])); + Assert.That(scr.ExtendedSecurity, + Is.EqualTo(ex_security[i]), + string.Format(Localization.Extended_security_0, cards[i])); - Assert.AreEqual(sd_spec4[i], scr.Spec4, string.Format(Localization.Spec_4_0, cards[i])); - Assert.AreEqual(sd_specx[i], scr.SpecX, string.Format(Localization.Spec_X_0, cards[i])); + Assert.That(scr.Spec4, Is.EqualTo(sd_spec4[i]), string.Format(Localization.Spec_4_0, cards[i])); + Assert.That(scr.SpecX, Is.EqualTo(sd_specx[i]), string.Format(Localization.Spec_X_0, cards[i])); - Assert.AreEqual((CommandSupport)cmd_support[i], - scr.CommandSupport, - string.Format(Localization.Command_support_0, cards[i])); + Assert.That(scr.CommandSupport, + Is.EqualTo((CommandSupport)cmd_support[i]), + string.Format(Localization.Command_support_0, cards[i])); - Assert.AreEqual(mfg[i], - scr.ManufacturerReserved, - string.Format(Localization.Manufacturer_reserved_0, cards[i])); + Assert.That(scr.ManufacturerReserved, + Is.EqualTo(mfg[i]), + string.Format(Localization.Manufacturer_reserved_0, cards[i])); }); } } diff --git a/Aaru.Tests/Filesystems/FilesystemTest.cs b/Aaru.Tests/Filesystems/FilesystemTest.cs index cb9478989..3469e7645 100644 --- a/Aaru.Tests/Filesystems/FilesystemTest.cs +++ b/Aaru.Tests/Filesystems/FilesystemTest.cs @@ -37,7 +37,7 @@ public abstract class FilesystemTest(string fileSystemType) string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -45,15 +45,15 @@ public abstract class FilesystemTest(string fileSystemType) IFilter inputFilter = PluginRegister.Singleton.GetFilter(testFile); - Assert.IsNotNull(inputFilter, string.Format(Localization.Filter_0, testFile)); + Assert.That(inputFilter, Is.Not.Null, string.Format(Localization.Filter_0, testFile)); var image = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(image, string.Format(Localization.Image_format_0, testFile)); + Assert.That(image, Is.Not.Null, string.Format(Localization.Image_format_0, testFile)); - Assert.AreEqual(ErrorNumber.NoError, - image.Open(inputFilter), - string.Format(Localization.Cannot_open_image_for_0, testFile)); + Assert.That(image.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Cannot_open_image_for_0, testFile)); List idPlugins; @@ -61,9 +61,9 @@ public abstract class FilesystemTest(string fileSystemType) { List partitionsList = Core.Partitions.GetAll(image); - Assert.Greater(partitionsList.Count, - 0, - string.Format(Localization.No_partitions_found_for_0, testFile)); + Assert.That(partitionsList, + Is.Not.Empty, + string.Format(Localization.No_partitions_found_for_0, testFile)); var found = false; @@ -80,7 +80,7 @@ public abstract class FilesystemTest(string fileSystemType) break; } - Assert.True(found, string.Format(Localization.Filesystem_not_identified_for_0, testFile)); + Assert.That(found, string.Format(Localization.Filesystem_not_identified_for_0, testFile)); } else { @@ -93,11 +93,12 @@ public abstract class FilesystemTest(string fileSystemType) Core.Filesystems.Identify(image, out idPlugins, wholePart, true); - Assert.Greater(idPlugins.Count, - 0, - string.Format(Localization.No_filesystems_found_for_0, testFile)); + Assert.That(idPlugins, + Is.Not.Empty, + string.Format(Localization.No_filesystems_found_for_0, testFile)); - Assert.True(idPlugins.Contains(Plugin.Id.ToString()), + Assert.That(idPlugins, + Does.Contain(Plugin.Id.ToString()), string.Format(Localization.Not_identified_for_0, testFile)); } } @@ -116,7 +117,7 @@ public abstract class FilesystemTest(string fileSystemType) string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -124,19 +125,19 @@ public abstract class FilesystemTest(string fileSystemType) IFilter inputFilter = PluginRegister.Singleton.GetFilter(testFile); - Assert.IsNotNull(inputFilter, string.Format(Localization.Filter_0, testFile)); + Assert.That(inputFilter, Is.Not.Null, string.Format(Localization.Filter_0, testFile)); var image = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(image, string.Format(Localization.Image_format_0, testFile)); + Assert.That(image, Is.Not.Null, string.Format(Localization.Image_format_0, testFile)); - Assert.AreEqual(ErrorNumber.NoError, - image.Open(inputFilter), - string.Format(Localization.Cannot_open_image_for_0, testFile)); + Assert.That(image.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Cannot_open_image_for_0, testFile)); - Assert.AreEqual(test.MediaType, image.Info.MediaType, testFile); - Assert.AreEqual(test.Sectors, image.Info.Sectors, testFile); - Assert.AreEqual(test.SectorSize, image.Info.SectorSize, testFile); + Assert.That(image.Info.MediaType, Is.EqualTo(test.MediaType), testFile); + Assert.That(image.Info.Sectors, Is.EqualTo(test.Sectors), testFile); + Assert.That(image.Info.SectorSize, Is.EqualTo(test.SectorSize), testFile); } }); } @@ -155,7 +156,7 @@ public abstract class FilesystemTest(string fileSystemType) var partition = new Partition(); bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -163,15 +164,15 @@ public abstract class FilesystemTest(string fileSystemType) IFilter inputFilter = PluginRegister.Singleton.GetFilter(testFile); - Assert.IsNotNull(inputFilter, string.Format(Localization.Filter_0, testFile)); + Assert.That(inputFilter, Is.Not.Null, string.Format(Localization.Filter_0, testFile)); var image = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(image, string.Format(Localization.Image_format_0, testFile)); + Assert.That(image, Is.Not.Null, string.Format(Localization.Image_format_0, testFile)); - Assert.AreEqual(ErrorNumber.NoError, - image.Open(inputFilter), - string.Format(Localization.Cannot_open_image_for_0, testFile)); + Assert.That(image.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Cannot_open_image_for_0, testFile)); List idPlugins; @@ -179,9 +180,9 @@ public abstract class FilesystemTest(string fileSystemType) { List partitionsList = Core.Partitions.GetAll(image); - Assert.Greater(partitionsList.Count, - 0, - string.Format(Localization.No_partitions_found_for_0, testFile)); + Assert.That(partitionsList, + Is.Not.Empty, + string.Format(Localization.No_partitions_found_for_0, testFile)); // In reverse to skip boot partitions we're not interested in for(int index = partitionsList.Count - 1; index >= 0; index--) @@ -209,14 +210,14 @@ public abstract class FilesystemTest(string fileSystemType) Core.Filesystems.Identify(image, out idPlugins, partition, true); - Assert.Greater(idPlugins.Count, - 0, - string.Format(Localization.No_filesystems_found_for_0, testFile)); + Assert.That(idPlugins, + Is.Not.Empty, + string.Format(Localization.No_filesystems_found_for_0, testFile)); found = idPlugins.Contains(Plugin.Id.ToString()); } - Assert.True(found, string.Format(Localization.Filesystem_not_identified_for_0, testFile)); + Assert.That(found, string.Format(Localization.Filesystem_not_identified_for_0, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It is not the case, it changes @@ -224,42 +225,49 @@ public abstract class FilesystemTest(string fileSystemType) var fs = Activator.CreateInstance(Plugin.GetType()) as IFilesystem; - Assert.NotNull(fs, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + Assert.That(fs, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); fs.GetInformation(image, partition, null, out _, out FileSystem fsMetadata); if(test.ApplicationId != null) { - Assert.AreEqual(test.ApplicationId, - fsMetadata.ApplicationIdentifier, - string.Format(Localization.Application_ID_0, testFile)); + Assert.That(fsMetadata.ApplicationIdentifier, + Is.EqualTo(test.ApplicationId), + string.Format(Localization.Application_ID_0, testFile)); } - Assert.AreEqual(test.Bootable, fsMetadata.Bootable, string.Format(Localization.Bootable_0, testFile)); - Assert.AreEqual(test.Clusters, fsMetadata.Clusters, string.Format(Localization.Clusters_0, testFile)); + Assert.That(fsMetadata.Bootable, + Is.EqualTo(test.Bootable), + string.Format(Localization.Bootable_0, testFile)); - Assert.AreEqual(test.ClusterSize, - fsMetadata.ClusterSize, - string.Format(Localization.Cluster_size_0, testFile)); + Assert.That(fsMetadata.Clusters, + Is.EqualTo(test.Clusters), + string.Format(Localization.Clusters_0, testFile)); + + Assert.That(fsMetadata.ClusterSize, + Is.EqualTo(test.ClusterSize), + string.Format(Localization.Cluster_size_0, testFile)); if(test.SystemId != null) { - Assert.AreEqual(test.SystemId, - fsMetadata.SystemIdentifier, - string.Format(Localization.System_ID_0, testFile)); + Assert.That(fsMetadata.SystemIdentifier, + Is.EqualTo(test.SystemId), + string.Format(Localization.System_ID_0, testFile)); } - Assert.AreEqual(fileSystemType ?? test.Type, - fsMetadata.Type, - string.Format(Localization.Filesystem_type_0, testFile)); + Assert.That(fsMetadata.Type, + Is.EqualTo(fileSystemType ?? test.Type), + string.Format(Localization.Filesystem_type_0, testFile)); - Assert.AreEqual(test.VolumeName, - fsMetadata.VolumeName, - string.Format(Localization.Volume_name_0, testFile)); + Assert.That(fsMetadata.VolumeName, + Is.EqualTo(test.VolumeName), + string.Format(Localization.Volume_name_0, testFile)); - Assert.AreEqual(test.VolumeSerial, - fsMetadata.VolumeSerial, - string.Format(Localization.Volume_serial_0, testFile)); + Assert.That(fsMetadata.VolumeSerial, + Is.EqualTo(test.VolumeSerial), + string.Format(Localization.Volume_serial_0, testFile)); } }); } diff --git a/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs b/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs index 4cf209601..b242520b0 100644 --- a/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs +++ b/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs @@ -36,7 +36,7 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest var partition = new Partition(); bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -44,15 +44,15 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest IFilter inputFilter = PluginRegister.Singleton.GetFilter(testFile); - Assert.IsNotNull(inputFilter, string.Format(Localization.Filter_0, testFile)); + Assert.That(inputFilter, Is.Not.Null, string.Format(Localization.Filter_0, testFile)); var image = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(image, string.Format(Localization.Image_format_0, testFile)); + Assert.That(image, Is.Not.Null, string.Format(Localization.Image_format_0, testFile)); - Assert.AreEqual(ErrorNumber.NoError, - image.Open(inputFilter), - string.Format(Localization.Cannot_open_image_for_0, testFile)); + Assert.That(image.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Cannot_open_image_for_0, testFile)); List idPlugins; @@ -60,9 +60,9 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest { List partitionsList = Core.Partitions.GetAll(image); - Assert.Greater(partitionsList.Count, - 0, - string.Format(Localization.No_partitions_found_for_0, testFile)); + Assert.That(partitionsList, + Is.Not.Empty, + string.Format(Localization.No_partitions_found_for_0, testFile)); // In reverse to skip boot partitions we're not interested in for(int index = partitionsList.Count - 1; index >= 0; index--) @@ -90,14 +90,14 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest Core.Filesystems.Identify(image, out idPlugins, partition, true); - Assert.Greater(idPlugins.Count, - 0, - string.Format(Localization.No_filesystems_found_for_0, testFile)); + Assert.That(idPlugins, + Is.Not.Empty, + string.Format(Localization.No_filesystems_found_for_0, testFile)); found = idPlugins.Contains(Plugin.Id.ToString()); } - Assert.True(found, string.Format(Localization.Filesystem_not_identified_for_0, testFile)); + Assert.That(found, string.Format(Localization.Filesystem_not_identified_for_0, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It is not the case, it changes @@ -105,13 +105,15 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest var fs = Activator.CreateInstance(Plugin.GetType()) as IReadOnlyFilesystem; - Assert.NotNull(fs, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + Assert.That(fs, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); test.Encoding ??= Encoding.ASCII; ErrorNumber ret = fs.Mount(image, partition, test.Encoding, null, test.Namespace); - Assert.AreEqual(ErrorNumber.NoError, ret, string.Format(Localization.Unmountable_0, testFile)); + Assert.That(ret, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Unmountable_0, testFile)); var serializerOptions = new JsonSerializerOptions { @@ -349,12 +351,9 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest // Directory is not readable, probably filled the volume, just ignore it if(ret == ErrorNumber.InvalidArgument) return; - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Unexpected_error_0_when_reading_directory_1_of_2, - ret, - path, - testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Unexpected_error_0_when_reading_directory_1_of_2, ret, path, testFile)); if(ret != ErrorNumber.NoError) return; @@ -387,12 +386,12 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest contents.Remove(child.Key); - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Unexpected_error_0_retrieving_stats_for_1_in_2, - ret, - childPath, - testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Unexpected_error_0_retrieving_stats_for_1_in_2, + ret, + childPath, + testFile)); if(child.Value.Info is not null) { @@ -437,18 +436,18 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest { ret = fs.OpenFile(childPath, out _); - Assert.AreEqual(ErrorNumber.IsDirectory, - ret, - string.Format(Localization.Got_wrong_data_for_directory_0_in_1, childPath, testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.IsDirectory), + string.Format(Localization.Got_wrong_data_for_directory_0_in_1, childPath, testFile)); // Cannot serialize to JSON too many depth levels 🤷‍♀️ if(currentDepth < 384) { - Assert.IsNotNull(child.Value.Children, - string.Format(Localization - .Contents_for_0_in_1_must_be_defined_in_unit_test_declaration, - childPath, - testFile)); + Assert.That(child.Value.Children, + Is.Not.Null, + string.Format(Localization.Contents_for_0_in_1_must_be_defined_in_unit_test_declaration, + childPath, + testFile)); if(child.Value.Children != null) { @@ -462,17 +461,13 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest { ret = fs.ReadLink(childPath, out string link); - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Got_wrong_data_for_symbolic_link_0_in_1, - childPath, - testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Got_wrong_data_for_symbolic_link_0_in_1, childPath, testFile)); - Assert.AreEqual(child.Value.LinkTarget, - link, - string.Format(Localization.Invalid_target_for_symbolic_link_0_in_1, - childPath, - testFile)); + Assert.That(link, + Is.EqualTo(child.Value.LinkTarget), + string.Format(Localization.Invalid_target_for_symbolic_link_0_in_1, childPath, testFile)); } else @@ -485,48 +480,52 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest if(ret == ErrorNumber.NotSupported) { - Assert.IsNull(child.Value.XattrsWithMd5, - string.Format(Localization - .Defined_extended_attributes_for_0_in_1_are_not_supported_by_filesystem, - childPath, - testFile)); + Assert.That(child.Value.XattrsWithMd5, + Is.Null, + string.Format(Localization + .Defined_extended_attributes_for_0_in_1_are_not_supported_by_filesystem, + childPath, + testFile)); continue; } - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Unexpected_error_0_when_listing_extended_attributes_for_1_in_2, - ret, - childPath, - testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Unexpected_error_0_when_listing_extended_attributes_for_1_in_2, + ret, + childPath, + testFile)); if(xattrs.Count > 0) { - Assert.IsNotNull(child.Value.XattrsWithMd5, - string.Format(Localization - .Extended_attributes_for_0_in_1_must_be_defined_in_unit_test_declaration, - childPath, - testFile)); + Assert.That(child.Value.XattrsWithMd5, + Is.Not.Null, + string.Format(Localization + .Extended_attributes_for_0_in_1_must_be_defined_in_unit_test_declaration, + childPath, + testFile)); } if(xattrs.Count > 0 || child.Value.XattrsWithMd5?.Count > 0) TestFileXattrs(fs, childPath, child.Value.XattrsWithMd5, testFile); } - Assert.IsEmpty(expectedNotFound, - string.Format(Localization.Could_not_find_the_children_of_0_in_1_2, - path, - testFile, - string.Join(" ", expectedNotFound))); + Assert.That(expectedNotFound, + Is.Empty, + string.Format(Localization.Could_not_find_the_children_of_0_in_1_2, + path, + testFile, + string.Join(" ", expectedNotFound))); if(contents != null) { - Assert.IsEmpty(contents, - string.Format(Localization.Found_the_following_unexpected_children_of_0_in_1_2, - path, - testFile, - string.Join(" ", contents))); + Assert.That(contents, + Is.Empty, + string.Format(Localization.Found_the_following_unexpected_children_of_0_in_1_2, + path, + testFile, + string.Join(" ", contents))); } } @@ -535,31 +534,31 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest var buffer = new byte[length]; ErrorNumber ret = fs.OpenFile(path, out IFileNode fileNode); - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Unexpected_error_0_when_reading_1_in_2, ret, path, testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Unexpected_error_0_when_reading_1_in_2, ret, path, testFile)); ret = fs.ReadFile(fileNode, length, buffer, out long readBytes); - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Unexpected_error_0_when_reading_1_in_2, ret, path, testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Unexpected_error_0_when_reading_1_in_2, ret, path, testFile)); - Assert.AreEqual(length, - readBytes, - string.Format(Localization.Got_less_bytes_0_than_expected_1_when_reading_2_in_3, - readBytes, - length, - path, - testFile)); + Assert.That(readBytes, + Is.EqualTo(length), + string.Format(Localization.Got_less_bytes_0_than_expected_1_when_reading_2_in_3, + readBytes, + length, + path, + testFile)); fs.CloseFile(fileNode); string data = Md5Context.Data(buffer, out _); - Assert.AreEqual(md5, - data, - string.Format(Localization.Got_MD5_0_for_1_in_2_but_expected_3, data, path, testFile, md5)); + Assert.That(data, + Is.EqualTo(md5), + string.Format(Localization.Got_MD5_0_for_1_in_2_but_expected_3, data, path, testFile, md5)); } static void TestFileXattrs(IReadOnlyFilesystem fs, string path, Dictionary xattrs, string testFile) @@ -590,37 +589,39 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest // Partially read extended attribute... dunno why it happens with some Toast images if(ret != ErrorNumber.OutOfRange) { - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Unexpected_error_0_retrieving_extended_attributes_for_1_in_2, - ret, - path, - testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Unexpected_error_0_retrieving_extended_attributes_for_1_in_2, + ret, + path, + testFile)); } string data = Md5Context.Data(buffer, out _); - Assert.AreEqual(xattr.Value, - data, - string.Format(Localization.Got_MD5_0_for_1_of_2_in_3_but_expected_4, - data, - xattr.Key, - path, - testFile, - xattr.Value)); + Assert.That(data, + Is.EqualTo(xattr.Value), + string.Format(Localization.Got_MD5_0_for_1_of_2_in_3_but_expected_4, + data, + xattr.Key, + path, + testFile, + xattr.Value)); } - Assert.IsEmpty(expectedNotFound, - string.Format(Localization.Could_not_find_the_following_extended_attributes_of_0_in_1_2, - path, - testFile, - string.Join(" ", expectedNotFound))); + Assert.That(expectedNotFound, + Is.Empty, + string.Format(Localization.Could_not_find_the_following_extended_attributes_of_0_in_1_2, + path, + testFile, + string.Join(" ", expectedNotFound))); - Assert.IsEmpty(contents, - string.Format(Localization.Found_the_following_unexpected_extended_attributes_of_0_in_1_2, - path, - testFile, - string.Join(" ", contents))); + Assert.That(contents, + Is.Empty, + string.Format(Localization.Found_the_following_unexpected_extended_attributes_of_0_in_1_2, + path, + testFile, + string.Join(" ", contents))); } #region Nested type: NextLevel diff --git a/Aaru.Tests/Filters/AppleDoubleDave.cs b/Aaru.Tests/Filters/AppleDoubleDave.cs index d4d478f06..732e890db 100644 --- a/Aaru.Tests/Filters/AppleDoubleDave.cs +++ b/Aaru.Tests/Filters/AppleDoubleDave.cs @@ -1,4 +1,4 @@ -// /*************************************************************************** +// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // @@ -65,24 +65,24 @@ public class AppleDoubleDave str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); result = Md5Context.File(_sidecar, out _); - Assert.AreEqual(EXPECTED_SIDECAR, result); + Assert.That(result, Is.EqualTo(EXPECTED_SIDECAR)); } [Test] public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -97,19 +97,19 @@ public class AppleDoubleDave str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/AppleDoubleDos.cs b/Aaru.Tests/Filters/AppleDoubleDos.cs index 40e3fb298..3d2994da1 100644 --- a/Aaru.Tests/Filters/AppleDoubleDos.cs +++ b/Aaru.Tests/Filters/AppleDoubleDos.cs @@ -64,24 +64,24 @@ public class AppleDoubleDos str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); result = Md5Context.File(_sidecar, out _); - Assert.AreEqual(EXPECTED_SIDECAR, result); + Assert.That(result, Is.EqualTo(EXPECTED_SIDECAR)); } [Test] public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -96,19 +96,19 @@ public class AppleDoubleDos str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/AppleDoubleNetatalk.cs b/Aaru.Tests/Filters/AppleDoubleNetatalk.cs index c944f24f7..04bc2bc5a 100644 --- a/Aaru.Tests/Filters/AppleDoubleNetatalk.cs +++ b/Aaru.Tests/Filters/AppleDoubleNetatalk.cs @@ -70,24 +70,24 @@ public class AppleDoubleNetatalk str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); result = Md5Context.File(_sidecar, out _); - Assert.AreEqual(EXPECTED_SIDECAR, result); + Assert.That(result, Is.EqualTo(EXPECTED_SIDECAR)); } [Test] public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -102,19 +102,19 @@ public class AppleDoubleNetatalk str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/AppleDoubleOsX.cs b/Aaru.Tests/Filters/AppleDoubleOsX.cs index 6e1e93a63..d5805ddae 100644 --- a/Aaru.Tests/Filters/AppleDoubleOsX.cs +++ b/Aaru.Tests/Filters/AppleDoubleOsX.cs @@ -64,24 +64,24 @@ public class AppleDoubleOsX str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); result = Md5Context.File(_sidecar, out _); - Assert.AreEqual(EXPECTED_SIDECAR, result); + Assert.That(result, Is.EqualTo(EXPECTED_SIDECAR)); } [Test] public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -96,19 +96,19 @@ public class AppleDoubleOsX str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/AppleDoubleProDos.cs b/Aaru.Tests/Filters/AppleDoubleProDos.cs index bcb15170f..03172fa56 100644 --- a/Aaru.Tests/Filters/AppleDoubleProDos.cs +++ b/Aaru.Tests/Filters/AppleDoubleProDos.cs @@ -64,24 +64,24 @@ public class AppleDoubleProDos str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); result = Md5Context.File(_sidecar, out _); - Assert.AreEqual(EXPECTED_SIDECAR, result); + Assert.That(result, Is.EqualTo(EXPECTED_SIDECAR)); } [Test] public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -96,19 +96,19 @@ public class AppleDoubleProDos str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/AppleDoubleUnAr.cs b/Aaru.Tests/Filters/AppleDoubleUnAr.cs index ecaebce0a..f5b6db7d6 100644 --- a/Aaru.Tests/Filters/AppleDoubleUnAr.cs +++ b/Aaru.Tests/Filters/AppleDoubleUnAr.cs @@ -64,24 +64,24 @@ public class AppleDoubleUnAr str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); result = Md5Context.File(_sidecar, out _); - Assert.AreEqual(EXPECTED_SIDECAR, result); + Assert.That(result, Is.EqualTo(EXPECTED_SIDECAR)); } [Test] public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -96,19 +96,19 @@ public class AppleDoubleUnAr str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/AppleDoubleUnix.cs b/Aaru.Tests/Filters/AppleDoubleUnix.cs index 6ed8d1e7b..091fe5171 100644 --- a/Aaru.Tests/Filters/AppleDoubleUnix.cs +++ b/Aaru.Tests/Filters/AppleDoubleUnix.cs @@ -64,24 +64,24 @@ public class AppleDoubleUnix str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); result = Md5Context.File(_sidecar, out _); - Assert.AreEqual(EXPECTED_SIDECAR, result); + Assert.That(result, Is.EqualTo(EXPECTED_SIDECAR)); } [Test] public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -96,19 +96,19 @@ public class AppleDoubleUnix str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/AppleSingle.cs b/Aaru.Tests/Filters/AppleSingle.cs index 95af41cc4..6ab78dd1a 100644 --- a/Aaru.Tests/Filters/AppleSingle.cs +++ b/Aaru.Tests/Filters/AppleSingle.cs @@ -57,21 +57,21 @@ public class AppleSingle str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.AppleSingle(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -86,19 +86,19 @@ public class AppleSingle str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new Aaru.Filters.AppleSingle(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/BZip2.cs b/Aaru.Tests/Filters/BZip2.cs index 0beb442e1..34c7c73bb 100644 --- a/Aaru.Tests/Filters/BZip2.cs +++ b/Aaru.Tests/Filters/BZip2.cs @@ -62,33 +62,33 @@ public class BZip2 str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(_expectedContents, result); + Assert.That(result, Is.EqualTo(_expectedContents)); } [Test] public void CheckCorrectFile() { byte[] result = Md5Context.File(_location); - Assert.AreEqual(_expectedFile, result); + Assert.That(result, Is.EqualTo(_expectedFile)); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.BZip2(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] public void Test() { IFilter filter = new Aaru.Filters.BZip2(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(1048576, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(0, filter.ResourceForkLength); - Assert.AreEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(false, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(1048576)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(0)); + Assert.That(filter.GetResourceForkStream(), Is.EqualTo(null)); + Assert.That(filter.HasResourceFork, Is.EqualTo(false)); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/GZip.cs b/Aaru.Tests/Filters/GZip.cs index f2194872c..b136fc0b2 100644 --- a/Aaru.Tests/Filters/GZip.cs +++ b/Aaru.Tests/Filters/GZip.cs @@ -1,4 +1,4 @@ -// /*************************************************************************** +// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // @@ -62,33 +62,33 @@ public class GZip str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(_expectedContents, result); + Assert.That(result, Is.EqualTo(_expectedContents)); } [Test] public void CheckCorrectFile() { byte[] result = Md5Context.File(_location); - Assert.AreEqual(_expectedFile, result); + Assert.That(result, Is.EqualTo(_expectedFile)); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.GZip(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] public void Test() { IFilter filter = new Aaru.Filters.GZip(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(1048576, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(0, filter.ResourceForkLength); - Assert.AreEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(false, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(1048576)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(0)); + Assert.That(filter.GetResourceForkStream(), Is.EqualTo(null)); + Assert.That(filter.HasResourceFork, Is.EqualTo(false)); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/LZip.cs b/Aaru.Tests/Filters/LZip.cs index fcefa43e0..47e7f206f 100644 --- a/Aaru.Tests/Filters/LZip.cs +++ b/Aaru.Tests/Filters/LZip.cs @@ -62,33 +62,33 @@ public class LZip str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(_expectedContents, result); + Assert.That(result, Is.EqualTo(_expectedContents)); } [Test] public void CheckCorrectFile() { byte[] result = Md5Context.File(_location); - Assert.AreEqual(_expectedFile, result); + Assert.That(result, Is.EqualTo(_expectedFile)); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.LZip(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] public void Test() { IFilter filter = new Aaru.Filters.LZip(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(1048576, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(0, filter.ResourceForkLength); - Assert.AreEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(false, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(1048576)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(0)); + Assert.That(filter.GetResourceForkStream(), Is.EqualTo(null)); + Assert.That(filter.HasResourceFork, Is.EqualTo(false)); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/MacBinary1.cs b/Aaru.Tests/Filters/MacBinary1.cs index c07bbabf3..c7a7de90f 100644 --- a/Aaru.Tests/Filters/MacBinary1.cs +++ b/Aaru.Tests/Filters/MacBinary1.cs @@ -58,21 +58,21 @@ public class MacBinary1 str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); } [Test] public void CheckFilterId() { IFilter filter = new MacBinary(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -87,19 +87,19 @@ public class MacBinary1 str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new MacBinary(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/MacBinary2.cs b/Aaru.Tests/Filters/MacBinary2.cs index 964411125..8987c1c22 100644 --- a/Aaru.Tests/Filters/MacBinary2.cs +++ b/Aaru.Tests/Filters/MacBinary2.cs @@ -58,21 +58,21 @@ public class MacBinary2 str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); } [Test] public void CheckFilterId() { IFilter filter = new MacBinary(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -87,19 +87,19 @@ public class MacBinary2 str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new MacBinary(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/MacBinary3.cs b/Aaru.Tests/Filters/MacBinary3.cs index 38f3b9999..b04932c2b 100644 --- a/Aaru.Tests/Filters/MacBinary3.cs +++ b/Aaru.Tests/Filters/MacBinary3.cs @@ -58,21 +58,21 @@ public class MacBinary3 str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] public void CheckCorrectFile() { string result = Md5Context.File(_location, out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); } [Test] public void CheckFilterId() { IFilter filter = new MacBinary(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -87,19 +87,19 @@ public class MacBinary3 str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new MacBinary(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(286, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(286)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/PCExchange.cs b/Aaru.Tests/Filters/PCExchange.cs index c9a7aa85b..8fdf9d2a7 100644 --- a/Aaru.Tests/Filters/PCExchange.cs +++ b/Aaru.Tests/Filters/PCExchange.cs @@ -58,7 +58,7 @@ public class PcExchange str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_CONTENTS, result); + Assert.That(result, Is.EqualTo(EXPECTED_CONTENTS)); } [Test] @@ -67,14 +67,14 @@ public class PcExchange string result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "Filters", "PC Exchange", "FINDER.DAT"), out _); - Assert.AreEqual(EXPECTED_FILE, result); + Assert.That(result, Is.EqualTo(EXPECTED_FILE)); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.PcExchange(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] @@ -89,19 +89,19 @@ public class PcExchange str.Dispose(); filter.Close(); string result = Md5Context.Data(data, out _); - Assert.AreEqual(EXPECTED_RESOURCE, result); + Assert.That(result, Is.EqualTo(EXPECTED_RESOURCE)); } [Test] public void Test() { IFilter filter = new Aaru.Filters.PcExchange(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(737280, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(546, filter.ResourceForkLength); - Assert.AreNotEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(true, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(737280)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(546)); + Assert.That(filter.GetResourceForkStream(), Is.Not.Null); + Assert.That(filter.HasResourceFork, Is.True); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Filters/XZ.cs b/Aaru.Tests/Filters/XZ.cs index 202e85a80..e45e4accd 100644 --- a/Aaru.Tests/Filters/XZ.cs +++ b/Aaru.Tests/Filters/XZ.cs @@ -63,33 +63,33 @@ public class Xz str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(_expectedContents, result); + Assert.That(result, Is.EqualTo(_expectedContents)); } [Test] public void CheckCorrectFile() { byte[] result = Md5Context.File(_location); - Assert.AreEqual(_expectedFile, result); + Assert.That(result, Is.EqualTo(_expectedFile)); } [Test] public void CheckFilterId() { IFilter filter = new XZ(); - Assert.AreEqual(true, filter.Identify(_location)); + Assert.That(filter.Identify(_location), Is.True); } [Test] public void Test() { IFilter filter = new XZ(); - Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); - Assert.AreEqual(1048576, filter.DataForkLength); - Assert.AreNotEqual(null, filter.GetDataForkStream()); - Assert.AreEqual(0, filter.ResourceForkLength); - Assert.AreEqual(null, filter.GetResourceForkStream()); - Assert.AreEqual(false, filter.HasResourceFork); + Assert.That(filter.Open(_location), Is.EqualTo(ErrorNumber.NoError)); + Assert.That(filter.DataForkLength, Is.EqualTo(1048576)); + Assert.That(filter.GetDataForkStream(), Is.Not.Null); + Assert.That(filter.ResourceForkLength, Is.EqualTo(0)); + Assert.That(filter.GetResourceForkStream(), Is.EqualTo(null)); + Assert.That(filter.HasResourceFork, Is.EqualTo(false)); filter.Close(); } } \ No newline at end of file diff --git a/Aaru.Tests/Helpers/Marshal.cs b/Aaru.Tests/Helpers/Marshal.cs index 4b007b025..dfb374322 100644 --- a/Aaru.Tests/Helpers/Marshal.cs +++ b/Aaru.Tests/Helpers/Marshal.cs @@ -23,9 +23,9 @@ public class Marshal { int count = Aaru.Helpers.Marshal.ConvertFromHexAscii(_testStrings[i], out byte[] buf); - Assert.AreEqual(_resultBytes[i].Length, buf.Length); - Assert.AreEqual(_resultBytes[i].Length, count); - Assert.AreEqual(_resultBytes[i], buf); + Assert.That(buf, Has.Length.EqualTo(_resultBytes[i].Length)); + Assert.That(count, Is.EqualTo(_resultBytes[i].Length)); + Assert.That(buf, Is.EqualTo(_resultBytes[i])); } } } \ No newline at end of file diff --git a/Aaru.Tests/Images/BlockMediaImageTest.cs b/Aaru.Tests/Images/BlockMediaImageTest.cs index 1b31af057..7de19bd96 100644 --- a/Aaru.Tests/Images/BlockMediaImageTest.cs +++ b/Aaru.Tests/Images/BlockMediaImageTest.cs @@ -35,7 +35,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -45,10 +45,13 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as IMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -56,17 +59,17 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest { Assert.Multiple(() => { - Assert.AreEqual(test.Sectors, - image.Info.Sectors, - string.Format(Localization.Sectors_0, testFile)); + Assert.That(image.Info.Sectors, + Is.EqualTo(test.Sectors), + string.Format(Localization.Sectors_0, testFile)); - Assert.AreEqual(test.SectorSize, - image.Info.SectorSize, - string.Format(Localization.Sector_size_0, testFile)); + Assert.That(image.Info.SectorSize, + Is.EqualTo(test.SectorSize), + string.Format(Localization.Sector_size_0, testFile)); - Assert.AreEqual(test.MediaType, - image.Info.MediaType, - string.Format(Localization.Media_type_0, testFile)); + Assert.That(image.Info.MediaType, + Is.EqualTo(test.MediaType), + string.Format(Localization.Media_type_0, testFile)); }); } } @@ -86,7 +89,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -96,10 +99,13 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as IMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -122,11 +128,11 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest doneSectors += image.Info.Sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } - Assert.AreEqual(test.Md5, ctx.End(), string.Format(Localization.Hash_0, testFile)); + Assert.That(ctx.End(), Is.EqualTo(test.Md5), string.Format(Localization.Hash_0, testFile)); } }); } @@ -146,7 +152,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -156,10 +162,13 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as IMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -178,12 +187,12 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest }); } - Assert.AreEqual(test.Partitions.Length, - partitions.Count, - string.Format(Localization.Expected_0_partitions_in_1_but_found_2, - test.Partitions.Length, - testFile, - partitions.Count)); + Assert.That(partitions, + Has.Count.EqualTo(test.Partitions.Length), + string.Format(Localization.Expected_0_partitions_in_1_but_found_2, + test.Partitions.Length, + testFile, + partitions.Count)); using(new AssertionScope()) { @@ -194,23 +203,23 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest BlockPartitionVolumes expectedPartition = test.Partitions[i]; Partition foundPartition = partitions[i]; - Assert.AreEqual(expectedPartition.Start, - foundPartition.Start, - string.Format(Localization - .Expected_partition_0_to_start_at_sector_1_but_found_it_starts_at_2_in_3, - i, - expectedPartition.Start, - foundPartition.Start, - testFile)); + Assert.That(foundPartition.Start, + Is.EqualTo(expectedPartition.Start), + string.Format(Localization + .Expected_partition_0_to_start_at_sector_1_but_found_it_starts_at_2_in_3, + i, + expectedPartition.Start, + foundPartition.Start, + testFile)); - Assert.AreEqual(expectedPartition.Length, - foundPartition.Length, - string.Format(Localization - .Expected_partition_0_to_have_1_sectors_but_found_it_has_2_sectors_in_3, - i, - expectedPartition.Length, - foundPartition.Length, - testFile)); + Assert.That(foundPartition.Length, + Is.EqualTo(expectedPartition.Length), + string.Format(Localization + .Expected_partition_0_to_have_1_sectors_but_found_it_has_2_sectors_in_3, + i, + expectedPartition.Length, + foundPartition.Length, + testFile)); var expectedDataFilename = $"{testFile}.contents.partition{i}.json"; @@ -233,7 +242,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest VolumeData[] expectedData = JsonSerializer.Deserialize(sr, serializerOptions); sr.Close(); - Assert.NotNull(expectedData); + Assert.That(expectedData, Is.Not.Null); Core.Filesystems.Identify(image, out List idPlugins, partitions[i]); @@ -274,10 +283,10 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest if(idPlugins.Count == 0) continue; - Assert.AreEqual(expectedData.Length, - idPlugins.Count, - $"Expected {expectedData.Length} filesystems identified in partition {i - } but found {idPlugins.Count} in {testFile}"); + Assert.That(idPlugins, + Has.Count.EqualTo(expectedData.Length), + $"Expected {expectedData.Length} filesystems identified in partition {i + } but found {idPlugins.Count} in {testFile}"); for(var j = 0; j < idPlugins.Count; j++) { @@ -286,13 +295,15 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest if(!plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out IReadOnlyFilesystem fs)) continue; - Assert.IsNotNull(fs, $"Could not instantiate filesystem {pluginName} in {testFile}"); + Assert.That(fs, + Is.Not.Null, + $"Could not instantiate filesystem {pluginName} in {testFile}"); ErrorNumber error = fs.Mount(image, partitions[i], null, null, null); - Assert.AreEqual(ErrorNumber.NoError, - error, - $"Could not mount {pluginName} in partition {i} in {testFile}."); + Assert.That(error, + Is.EqualTo(ErrorNumber.NoError), + $"Could not mount {pluginName} in partition {i} in {testFile}."); if(error != ErrorNumber.NoError) continue; diff --git a/Aaru.Tests/Images/OpticalMediaImageTest.cs b/Aaru.Tests/Images/OpticalMediaImageTest.cs index 517121f6c..e6f4d139a 100644 --- a/Aaru.Tests/Images/OpticalMediaImageTest.cs +++ b/Aaru.Tests/Images/OpticalMediaImageTest.cs @@ -43,7 +43,7 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -53,10 +53,13 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as IOpticalMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -64,26 +67,26 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest { Assert.Multiple(() => { - Assert.AreEqual(test.Sectors, - image.Info.Sectors, - string.Format(Localization.Sectors_0, testFile)); + Assert.That(image.Info.Sectors, + Is.EqualTo(test.Sectors), + string.Format(Localization.Sectors_0, testFile)); if(test.SectorSize > 0) { - Assert.AreEqual(test.SectorSize, - image.Info.SectorSize, - string.Format(Localization.Sector_size_0, testFile)); + Assert.That(image.Info.SectorSize, + Is.EqualTo(test.SectorSize), + string.Format(Localization.Sector_size_0, testFile)); } - Assert.AreEqual(test.MediaType, - image.Info.MediaType, - string.Format(Localization.Media_type_0, testFile)); + Assert.That(image.Info.MediaType, + Is.EqualTo(test.MediaType), + string.Format(Localization.Media_type_0, testFile)); if(image.Info.MetadataMediaType != MetadataMediaType.OpticalDisc) return; - Assert.AreEqual(test.Tracks.Length, - image.Tracks.Count, - string.Format(Localization.Tracks_0, testFile)); + Assert.That(image.Tracks, + Has.Count.EqualTo(test.Tracks.Length), + string.Format(Localization.Tracks_0, testFile)); image.Tracks.Select(t => t.Session) .Should() @@ -133,11 +136,11 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest .BeEquivalentTo(test.Tracks.Select(s => s.Flags), string.Format(Localization.Track_flags_0, testFile)); - Assert.AreEqual(latestEndSector, - image.Info.Sectors - 1, - string.Format(Localization.Last_sector_for_tracks_is_0_but_it_is_1_for_image, - latestEndSector, - image.Info.Sectors)); + Assert.That(image.Info.Sectors - 1, + Is.EqualTo(latestEndSector), + string.Format(Localization.Last_sector_for_tracks_is_0_but_it_is_1_for_image, + latestEndSector, + image.Info.Sectors)); }); } } @@ -156,7 +159,7 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -166,10 +169,13 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as IOpticalMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -193,12 +199,12 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest Core.Filesystems.Identify(image, out List idPlugins, partition); - Assert.AreEqual(track.FileSystems.Length, - idPlugins.Count, - string.Format(Localization.Expected_0_filesystems_in_1_but_found_2, - track.FileSystems.Length, - testFile, - idPlugins.Count)); + Assert.That(idPlugins, + Has.Count.EqualTo(track.FileSystems.Length), + string.Format(Localization.Expected_0_filesystems_in_1_but_found_2, + track.FileSystems.Length, + testFile, + idPlugins.Count)); for(var i = 0; i < track.FileSystems.Length; i++) { @@ -209,49 +215,50 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest // It is not the case, it changes if(!found) continue; - Assert.NotNull(fs, - string.Format(Localization.Could_not_instantiate_filesystem_for_0, - testFile)); + Assert.That(fs, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, + testFile)); fs.GetInformation(image, partition, null, out _, out FileSystem fsMetadata); if(track.FileSystems[i].ApplicationId != null) { - Assert.AreEqual(track.FileSystems[i].ApplicationId, - fsMetadata.ApplicationIdentifier, - string.Format(Localization.Application_ID_0, testFile)); + Assert.That(fsMetadata.ApplicationIdentifier, + Is.EqualTo(track.FileSystems[i].ApplicationId), + string.Format(Localization.Application_ID_0, testFile)); } - Assert.AreEqual(track.FileSystems[i].Bootable, - fsMetadata.Bootable, - string.Format(Localization.Bootable_0, testFile)); + Assert.That(fsMetadata.Bootable, + Is.EqualTo(track.FileSystems[i].Bootable), + string.Format(Localization.Bootable_0, testFile)); - Assert.AreEqual(track.FileSystems[i].Clusters, - fsMetadata.Clusters, - string.Format(Localization.Clusters_0, testFile)); + Assert.That(fsMetadata.Clusters, + Is.EqualTo(track.FileSystems[i].Clusters), + string.Format(Localization.Clusters_0, testFile)); - Assert.AreEqual(track.FileSystems[i].ClusterSize, - fsMetadata.ClusterSize, - string.Format(Localization.Cluster_size_0, testFile)); + Assert.That(fsMetadata.ClusterSize, + Is.EqualTo(track.FileSystems[i].ClusterSize), + string.Format(Localization.Cluster_size_0, testFile)); if(track.FileSystems[i].SystemId != null) { - Assert.AreEqual(track.FileSystems[i].SystemId, - fsMetadata.SystemIdentifier, - string.Format(Localization.System_ID_0, testFile)); + Assert.That(fsMetadata.SystemIdentifier, + Is.EqualTo(track.FileSystems[i].SystemId), + string.Format(Localization.System_ID_0, testFile)); } - Assert.AreEqual(track.FileSystems[i].Type, - fsMetadata.Type, - string.Format(Localization.Filesystem_type_0, testFile)); + Assert.That(fsMetadata.Type, + Is.EqualTo(track.FileSystems[i].Type), + string.Format(Localization.Filesystem_type_0, testFile)); - Assert.AreEqual(track.FileSystems[i].VolumeName, - fsMetadata.VolumeName, - string.Format(Localization.Volume_name_0, testFile)); + Assert.That(fsMetadata.VolumeName, + Is.EqualTo(track.FileSystems[i].VolumeName), + string.Format(Localization.Volume_name_0, testFile)); - Assert.AreEqual(track.FileSystems[i].VolumeSerial, - fsMetadata.VolumeSerial, - string.Format(Localization.Volume_serial_0, testFile)); + Assert.That(fsMetadata.VolumeSerial, + Is.EqualTo(track.FileSystems[i].VolumeSerial), + string.Format(Localization.Volume_serial_0, testFile)); if(fs is not IReadOnlyFilesystem rofs) { @@ -259,12 +266,11 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest track.FileSystems[i].ContentsJson != null || File.Exists($"{testFile}.track{track.Number}.filesystem{i}.contents.json")) { - Assert.NotNull(null, - string.Format(Localization - .Could_not_instantiate_filesystem_for_0_track_1_filesystem_2, - testFile, - track.Number, - i)); + Assert.Fail(string.Format(Localization + .Could_not_instantiate_filesystem_for_0_track_1_filesystem_2, + testFile, + track.Number, + i)); } continue; @@ -278,9 +284,9 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest null, track.FileSystems[i].Namespace); - Assert.AreEqual(ErrorNumber.NoError, - ret, - string.Format(Localization.Unmountable_0, testFile)); + Assert.That(ret, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Unmountable_0, testFile)); var serializerOptions = new JsonSerializerOptions { @@ -375,7 +381,7 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest string testFile = Tests[i].TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -386,12 +392,15 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest var image = Activator.CreateInstance(Plugin.GetType()) as IOpticalMediaImage; - Assert.NotNull(image, - string.Format(Localization.Could_not_instantiate_filesystem_for_0, - testFile)); + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + + Assert.That(opened, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) return; @@ -444,15 +453,15 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest doneSectors += sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } } - Assert.AreEqual(@long ? Tests[i].LongMd5 : Tests[i].Md5, - ctx.End(), - $"{(@long ? "Long hash" : "Hash")}: {testFile}"); + Assert.That(ctx.End(), + Is.EqualTo(@long ? Tests[i].LongMd5 : Tests[i].Md5), + $"{(@long ? "Long hash" : "Hash")}: {testFile}"); } if(!image.Info.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) return; @@ -489,14 +498,14 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest doneSectors += sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } } - Assert.AreEqual(Tests[i].SubchannelMd5, - ctx.End(), - string.Format(Localization.Subchannel_hash_0, testFile)); + Assert.That(ctx.End(), + Is.EqualTo(Tests[i].SubchannelMd5), + string.Format(Localization.Subchannel_hash_0, testFile)); } else { @@ -521,11 +530,13 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest doneSectors += image.Info.Sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } - Assert.AreEqual(Tests[i].Md5, ctx.End(), string.Format(Localization.Hash_0, testFile)); + Assert.That(ctx.End(), + Is.EqualTo(Tests[i].Md5), + string.Format(Localization.Hash_0, testFile)); } }); }); diff --git a/Aaru.Tests/Images/TapeMediaImageTest.cs b/Aaru.Tests/Images/TapeMediaImageTest.cs index 9683362f9..71eb5bc54 100644 --- a/Aaru.Tests/Images/TapeMediaImageTest.cs +++ b/Aaru.Tests/Images/TapeMediaImageTest.cs @@ -34,7 +34,7 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -44,14 +44,17 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as ITapeImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; - Assert.AreEqual(true, image.IsTape, string.Format(Localization.Is_tape_0, testFile)); + Assert.That(image.IsTape, Is.True, string.Format(Localization.Is_tape_0, testFile)); using(new AssertionScope()) { @@ -80,7 +83,7 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -90,10 +93,13 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as IMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -101,17 +107,17 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest { Assert.Multiple(() => { - Assert.AreEqual(test.Sectors, - image.Info.Sectors, - string.Format(Localization.Sectors_0, testFile)); + Assert.That(image.Info.Sectors, + Is.EqualTo(test.Sectors), + string.Format(Localization.Sectors_0, testFile)); - Assert.AreEqual(test.SectorSize, - image.Info.SectorSize, - string.Format(Localization.Sector_size_0, testFile)); + Assert.That(image.Info.SectorSize, + Is.EqualTo(test.SectorSize), + string.Format(Localization.Sector_size_0, testFile)); - Assert.AreEqual(test.MediaType, - image.Info.MediaType, - string.Format(Localization.Media_type_0, testFile)); + Assert.That(image.Info.MediaType, + Is.EqualTo(test.MediaType), + string.Format(Localization.Media_type_0, testFile)); }); } } @@ -131,7 +137,7 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -141,10 +147,13 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(Plugin.GetType()) as IMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -167,11 +176,11 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest doneSectors += image.Info.Sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } - Assert.AreEqual(test.Md5, ctx.End(), string.Format(Localization.Hash_0, testFile)); + Assert.That(ctx.End(), Is.EqualTo(test.Md5), string.Format(Localization.Hash_0, testFile)); } }); } diff --git a/Aaru.Tests/Issues/FsExtractHashIssueTest.cs b/Aaru.Tests/Issues/FsExtractHashIssueTest.cs index 470b71263..a29d25fe9 100644 --- a/Aaru.Tests/Issues/FsExtractHashIssueTest.cs +++ b/Aaru.Tests/Issues/FsExtractHashIssueTest.cs @@ -42,7 +42,7 @@ public abstract class FsExtractHashIssueTest Dictionary 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 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(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 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 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); diff --git a/Aaru.Tests/Issues/FsExtractIssueTest.cs b/Aaru.Tests/Issues/FsExtractIssueTest.cs index 2ebed0f00..67e3da101 100644 --- a/Aaru.Tests/Issues/FsExtractIssueTest.cs +++ b/Aaru.Tests/Issues/FsExtractIssueTest.cs @@ -35,7 +35,7 @@ public abstract class FsExtractIssueTest Dictionary 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; @@ -45,15 +45,17 @@ public abstract class FsExtractIssueTest 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 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 { @@ -82,15 +84,17 @@ public abstract class FsExtractIssueTest { 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; 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)); ExtractFilesInDir("/", fs, Xattrs); } @@ -99,21 +103,21 @@ public abstract class FsExtractIssueTest { plugins.ReadOnlyFilesystems.TryGetValue(idPlugins[0], out IReadOnlyFilesystem fs); - Assert.IsNotNull(fs, string.Format(Localization.Could_not_instantiate_filesystem_0, fs?.Name)); + Assert.That(fs, Is.Not.Null, string.Format(Localization.Could_not_instantiate_filesystem_0, fs?.Name)); filesystemFound = true; error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); - Assert.AreEqual(ErrorNumber.NoError, - error, - string.Format(Localization.Could_not_mount_0_in_partition_1, fs.Name, i)); + Assert.That(error, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Could_not_mount_0_in_partition_1, fs.Name, i)); ExtractFilesInDir("/", fs, Xattrs); } } - Assert.IsTrue(filesystemFound, Localization.No_filesystems_found); + Assert.That(filesystemFound, Localization.No_filesystems_found); } static void ExtractFilesInDir(string path, IReadOnlyFilesystem fs, bool doXattrs) @@ -122,17 +126,17 @@ public abstract class FsExtractIssueTest 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)) { @@ -145,11 +149,11 @@ public abstract class FsExtractIssueTest { error = fs.ListXAttr(path + "/" + entry, out List 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)); if(error == ErrorNumber.NoError) { @@ -158,11 +162,11 @@ public abstract class FsExtractIssueTest 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)); } } } @@ -170,22 +174,19 @@ public abstract class FsExtractIssueTest 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.CloseDir(node); diff --git a/Aaru.Tests/Issues/ImageReadIssueTest.cs b/Aaru.Tests/Issues/ImageReadIssueTest.cs index e95b74e52..4d4e4ec20 100644 --- a/Aaru.Tests/Issues/ImageReadIssueTest.cs +++ b/Aaru.Tests/Issues/ImageReadIssueTest.cs @@ -25,17 +25,19 @@ public abstract class ImageReadIssueTest Environment.CurrentDirectory = DataFolder; bool exists = File.Exists(TestFile); - Assert.True(exists, Localization.Test_file_not_found); + Assert.That(exists, Localization.Test_file_not_found); IFilter inputFilter = PluginRegister.Singleton.GetFilter(TestFile); - Assert.IsNotNull(inputFilter, Localization.Filter_for_test_file_is_not_detected); + Assert.That(inputFilter, Is.Not.Null, Localization.Filter_for_test_file_is_not_detected); var image = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(image, Localization.Image_format_for_test_file_is_not_detected); + Assert.That(image, Is.Not.Null, Localization.Image_format_for_test_file_is_not_detected); - Assert.AreEqual(ErrorNumber.NoError, image.Open(inputFilter), Localization.Cannot_open_image_for_test_file); + Assert.That(image.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + Localization.Cannot_open_image_for_test_file); ulong doneSectors = 0; var ctx = new Crc32Context(); @@ -57,7 +59,7 @@ public abstract class ImageReadIssueTest doneSectors += image.Info.Sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } diff --git a/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs b/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs index 511a5b9a1..36c9122f6 100644 --- a/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs +++ b/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs @@ -52,37 +52,42 @@ public abstract class OpticalImageConvertIssueTest IFilter inputFilter = PluginRegister.Singleton.GetFilter(InputPath); - Assert.IsNotNull(inputFilter, Localization.Cannot_open_specified_file); + Assert.That(inputFilter, Is.Not.Null, Localization.Cannot_open_specified_file); string outputPath = Path.Combine(Path.GetTempPath(), SuggestedOutputFilename); - Assert.IsFalse(File.Exists(outputPath), Localization.Output_file_already_exists_not_continuing); + Assert.That(File.Exists(outputPath), Is.False, Localization.Output_file_already_exists_not_continuing); var inputFormat = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(inputFormat, Localization.Input_image_format_not_identified_not_proceeding_with_conversion); + Assert.That(inputFormat, + Is.Not.Null, + Localization.Input_image_format_not_identified_not_proceeding_with_conversion); - Assert.AreEqual(ErrorNumber.NoError, inputFormat.Open(inputFilter), Localization.Unable_to_open_image_format); + Assert.That(inputFormat.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + Localization.Unable_to_open_image_format); - Assert.IsTrue(OutputFormat.SupportedMediaTypes.Contains(inputFormat.Info.MediaType), - Localization.Output_format_does_not_support_media_type_cannot_continue); + Assert.That(OutputFormat.SupportedMediaTypes, + Does.Contain(inputFormat.Info.MediaType), + Localization.Output_format_does_not_support_media_type_cannot_continue); if(inputFormat.Info.ReadableSectorTags.Count == 0) - Assert.IsFalse(UseLong, Localization.Input_image_does_not_support_long_sectors); + Assert.That(UseLong, Is.False, Localization.Input_image_does_not_support_long_sectors); var inputOptical = inputFormat as IOpticalMediaImage; var outputOptical = OutputFormat as IWritableOpticalImage; - Assert.IsNotNull(inputOptical, Localization.Could_not_treat_existing_image_as_optical_disc); - Assert.IsNotNull(outputOptical, Localization.Could_not_treat_new_image_as_optical_disc); - Assert.IsNotNull(inputOptical.Tracks, Localization.Existing_image_contains_no_tracks); + Assert.That(inputOptical, Is.Not.Null, Localization.Could_not_treat_existing_image_as_optical_disc); + Assert.That(outputOptical, Is.Not.Null, Localization.Could_not_treat_new_image_as_optical_disc); + Assert.That(inputOptical.Tracks, Is.Not.Null, Localization.Existing_image_contains_no_tracks); - Assert.IsTrue(outputOptical.Create(outputPath, - inputFormat.Info.MediaType, - ParsedOptions, - inputFormat.Info.Sectors, - inputFormat.Info.SectorSize), - string.Format(Localization.Error_0_creating_output_image, outputOptical.ErrorMessage)); + Assert.That(outputOptical.Create(outputPath, + inputFormat.Info.MediaType, + ParsedOptions, + inputFormat.Info.Sectors, + inputFormat.Info.SectorSize), + string.Format(Localization.Error_0_creating_output_image, outputOptical.ErrorMessage)); var metadata = new ImageInfo { @@ -104,8 +109,8 @@ public abstract class OpticalImageConvertIssueTest MediaTitle = inputFormat.Info.MediaTitle }; - Assert.IsTrue(outputOptical.SetImageInfo(metadata), - string.Format(Localization.Error_0_setting_metadata, outputOptical.ErrorMessage)); + Assert.That(outputOptical.SetImageInfo(metadata), + string.Format(Localization.Error_0_setting_metadata, outputOptical.ErrorMessage)); Metadata aaruMetadata = inputFormat.AaruMetadata; List dumpHardware = inputFormat.DumpHardware; @@ -116,16 +121,16 @@ public abstract class OpticalImageConvertIssueTest AaruConsole.WriteLine(Localization.Converting_media_tag_0, mediaTag); errno = inputFormat.ReadMediaTag(mediaTag, out byte[] tag); - Assert.AreEqual(ErrorNumber.NoError, errno); - Assert.IsTrue(outputOptical.WriteMediaTag(tag, mediaTag)); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); + Assert.That(outputOptical.WriteMediaTag(tag, mediaTag)); } AaruConsole.WriteLine(Localization._0_sectors_to_convert, inputFormat.Info.Sectors); ulong doneSectors; - Assert.IsTrue(outputOptical.SetTracks(inputOptical.Tracks), - string.Format(Localization.Error_0_sending_tracks_list_to_output_image, - outputOptical.ErrorMessage)); + Assert.That(outputOptical.SetTracks(inputOptical.Tracks), + string.Format(Localization.Error_0_sending_tracks_list_to_output_image, + outputOptical.ErrorMessage)); foreach(Track track in inputOptical.Tracks) { @@ -172,17 +177,17 @@ public abstract class OpticalImageConvertIssueTest ? inputFormat.ReadSector(doneSectors + track.StartSector, out sector) : inputFormat.ReadSectors(doneSectors + track.StartSector, sectorsToDo, out sector); - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); result = sectorsToDo == 1 ? outputOptical.WriteSector(sector, doneSectors + track.StartSector) : outputOptical.WriteSectors(sector, doneSectors + track.StartSector, sectorsToDo); } - Assert.IsTrue(result, - string.Format(Localization.Error_0_writing_sector_1_not_continuing, - outputOptical.ErrorMessage, - doneSectors + track.StartSector)); + Assert.That(result, + string.Format(Localization.Error_0_writing_sector_1_not_continuing, + outputOptical.ErrorMessage, + doneSectors + track.StartSector)); doneSectors += sectorsToDo; } @@ -282,15 +287,15 @@ public abstract class OpticalImageConvertIssueTest if(errno == ErrorNumber.NoData) continue; - Assert.AreEqual(ErrorNumber.NoError, - errno, - string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); + Assert.That(errno, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); result = outputOptical.WriteSectorTag(sector, track.Sequence, tag); - Assert.IsTrue(result, - string.Format(Localization.Error_0_writing_tag_not_continuing, - outputOptical.ErrorMessage)); + Assert.That(result, + string.Format(Localization.Error_0_writing_tag_not_continuing, + outputOptical.ErrorMessage)); continue; } @@ -308,9 +313,9 @@ public abstract class OpticalImageConvertIssueTest { errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector); - Assert.AreEqual(ErrorNumber.NoError, - errno, - string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); + Assert.That(errno, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); if(tag == SectorTagType.CdSectorSubchannel) { @@ -349,9 +354,9 @@ public abstract class OpticalImageConvertIssueTest tag, out sector); - Assert.AreEqual(ErrorNumber.NoError, - errno, - string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); + Assert.That(errno, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); if(tag == SectorTagType.CdSectorSubchannel) { @@ -389,10 +394,10 @@ public abstract class OpticalImageConvertIssueTest } } - Assert.IsTrue(result, - string.Format(Localization.Error_0_writing_tag_for_sector_1_not_continuing, - outputOptical.ErrorMessage, - doneSectors + track.StartSector)); + Assert.That(result, + string.Format(Localization.Error_0_writing_tag_for_sector_1_not_continuing, + outputOptical.ErrorMessage, + doneSectors + track.StartSector)); doneSectors += sectorsToDo; } @@ -406,8 +411,10 @@ public abstract class OpticalImageConvertIssueTest } if(trackFlags.Count > 0) + { foreach((byte track, byte flags) in trackFlags) outputOptical.WriteSectorTag([flags], track, SectorTagType.CdTrackFlags); + } if(mcn != null) outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); @@ -425,7 +432,7 @@ public abstract class OpticalImageConvertIssueTest else if(aaruMetadata != null) outputOptical.SetMetadata(aaruMetadata); } - Assert.True(outputOptical.Close(), + Assert.That(outputOptical.Close(), string.Format(Localization.Error_0_closing_output_image_Contents_are_not_correct, outputOptical.ErrorMessage)); @@ -434,7 +441,7 @@ public abstract class OpticalImageConvertIssueTest { string md5 = Md5Context.File(outputPath, out _); - Assert.AreEqual(Md5, md5, Localization.Hashes_are_different); + Assert.That(md5, Is.EqualTo(Md5), Localization.Hashes_are_different); } File.Delete(outputPath); diff --git a/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs b/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs index 3d4603986..eaa1755e0 100644 --- a/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs +++ b/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs @@ -27,21 +27,23 @@ public abstract class OpticalImageReadIssueTest Environment.CurrentDirectory = DataFolder; bool exists = File.Exists(TestFile); - Assert.True(exists, Localization.Test_file_not_found); + Assert.That(exists, Localization.Test_file_not_found); IFilter inputFilter = PluginRegister.Singleton.GetFilter(TestFile); - Assert.IsNotNull(inputFilter, Localization.Filter_for_test_file_is_not_detected); + Assert.That(inputFilter, Is.Not.Null, Localization.Filter_for_test_file_is_not_detected); var image = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(image, Localization.Image_format_for_test_file_is_not_detected); + Assert.That(image, Is.Not.Null, Localization.Image_format_for_test_file_is_not_detected); - Assert.AreEqual(ErrorNumber.NoError, image.Open(inputFilter), Localization.Cannot_open_image_for_test_file); + Assert.That(image.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + Localization.Cannot_open_image_for_test_file); var opticalInput = image as IOpticalMediaImage; - Assert.IsNotNull(opticalInput, Localization.Image_format_for_test_file_is_not_for_an_optical_disc); + Assert.That(opticalInput, Is.Not.Null, Localization.Image_format_for_test_file_is_not_for_an_optical_disc); var ctx = new Crc32Context(); @@ -76,7 +78,7 @@ public abstract class OpticalImageReadIssueTest doneSectors += sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } diff --git a/Aaru.Tests/Partitions/PartitionSchemeTest.cs b/Aaru.Tests/Partitions/PartitionSchemeTest.cs index 93081cac0..f0988fa2c 100644 --- a/Aaru.Tests/Partitions/PartitionSchemeTest.cs +++ b/Aaru.Tests/Partitions/PartitionSchemeTest.cs @@ -27,7 +27,7 @@ public abstract class PartitionSchemeTest Environment.CurrentDirectory = DataFolder; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -38,15 +38,15 @@ public abstract class PartitionSchemeTest IFilter inputFilter = PluginRegister.Singleton.GetFilter(testFile); - Assert.IsNotNull(inputFilter, string.Format(Localization.Filter_0, testFile)); + Assert.That(inputFilter, Is.Not.Null, string.Format(Localization.Filter_0, testFile)); var image = ImageFormat.Detect(inputFilter) as IMediaImage; - Assert.IsNotNull(image, string.Format(Localization.Image_format_0, testFile)); + Assert.That(image, Is.Not.Null, string.Format(Localization.Image_format_0, testFile)); - Assert.AreEqual(ErrorNumber.NoError, - image.Open(inputFilter), - string.Format(Localization.Cannot_open_image_for_0, testFile)); + Assert.That(image.Open(inputFilter), + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Cannot_open_image_for_0, testFile)); List partitions = Core.Partitions.GetAll(image); diff --git a/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs b/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs index c6c2e64c4..640ae1985 100644 --- a/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs +++ b/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs @@ -38,7 +38,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -48,10 +48,13 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest filter.Open(testFile); var image = Activator.CreateInstance(InputPlugin.GetType()) as IOpticalMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_filesystem_for_0, testFile)); ErrorNumber opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -59,26 +62,26 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { Assert.Multiple(() => { - Assert.AreEqual(test.Sectors, - image.Info.Sectors, - string.Format(Localization.Sectors_0, testFile)); + Assert.That(image.Info.Sectors, + Is.EqualTo(test.Sectors), + string.Format(Localization.Sectors_0, testFile)); if(test.SectorSize > 0) { - Assert.AreEqual(test.SectorSize, - image.Info.SectorSize, - string.Format(Localization.Sector_size_0, testFile)); + Assert.That(image.Info.SectorSize, + Is.EqualTo(test.SectorSize), + string.Format(Localization.Sector_size_0, testFile)); } - Assert.AreEqual(test.MediaType, - image.Info.MediaType, - string.Format(Localization.Media_type_0, testFile)); + Assert.That(image.Info.MediaType, + Is.EqualTo(test.MediaType), + string.Format(Localization.Media_type_0, testFile)); if(image.Info.MetadataMediaType != MetadataMediaType.OpticalDisc) return; - Assert.AreEqual(test.Tracks.Length, - image.Tracks.Count, - string.Format(Localization.Tracks_0, testFile)); + Assert.That(image.Tracks, + Has.Count.EqualTo(test.Tracks.Length), + string.Format(Localization.Tracks_0, testFile)); image.Tracks.Select(t => t.Session) .Should() @@ -125,11 +128,11 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest .BeEquivalentTo(test.Tracks.Select(s => s.Flags), string.Format(Localization.Track_flags_0, testFile)); - Assert.AreEqual(latestEndSector, - image.Info.Sectors - 1, - string.Format(Localization.Last_sector_for_tracks_is_0_but_it_is_1_for_image, - latestEndSector, - image.Info.Sectors)); + Assert.That(image.Info.Sectors - 1, + Is.EqualTo(latestEndSector), + string.Format(Localization.Last_sector_for_tracks_is_0_but_it_is_1_for_image, + latestEndSector, + image.Info.Sectors)); }); } } @@ -149,7 +152,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest string testFile = test.TestFile; bool exists = File.Exists(testFile); - Assert.True(exists, string.Format(Localization._0_not_found, testFile)); + Assert.That(exists, string.Format(Localization._0_not_found, testFile)); // ReSharper disable once ConditionIsAlwaysTrueOrFalse // It arrives here... @@ -160,11 +163,12 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest var inputFormat = Activator.CreateInstance(InputPlugin.GetType()) as IOpticalMediaImage; - Assert.NotNull(inputFormat, - string.Format(Localization.Could_not_instantiate_input_plugin_for_0, testFile)); + Assert.That(inputFormat, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_input_plugin_for_0, testFile)); ErrorNumber opened = inputFormat.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_0, testFile)); + Assert.That(opened, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Open_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -172,13 +176,16 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest var outputFormat = Activator.CreateInstance(OutputPlugin.GetType()) as IWritableOpticalImage; - Assert.NotNull(outputFormat, - string.Format(Localization.Could_not_instantiate_output_plugin_for_0, testFile)); + Assert.That(outputFormat, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_output_plugin_for_0, testFile)); - Assert.IsTrue(outputFormat.SupportedMediaTypes.Contains(inputFormat.Info.MediaType), - string.Format(Localization.Trying_to_convert_unsupported_media_type_0_for_1, - inputFormat.Info.MediaType, - testFile)); + + Assert.That(outputFormat.SupportedMediaTypes, + Does.Contain(inputFormat.Info.MediaType), + string.Format(Localization.Trying_to_convert_unsupported_media_type_0_for_1, + inputFormat.Info.MediaType, + testFile)); bool useLong = inputFormat.Info.ReadableSectorTags.Except(new[] { @@ -196,12 +203,12 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest sectorTag != SectorTagType.CdSectorSubchannel)) useLong = false; - Assert.IsTrue(outputFormat.Create(outputPath, - inputFormat.Info.MediaType, - new Dictionary(), - inputFormat.Info.Sectors, - inputFormat.Info.SectorSize), - string.Format(Localization.Error_0_creating_output_image, outputFormat.ErrorMessage)); + Assert.That(outputFormat.Create(outputPath, + inputFormat.Info.MediaType, + new Dictionary(), + inputFormat.Info.Sectors, + inputFormat.Info.SectorSize), + string.Format(Localization.Error_0_creating_output_image, outputFormat.ErrorMessage)); foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags.Where(mediaTag => outputFormat.SupportedMediaTags.Contains(mediaTag))) @@ -210,9 +217,9 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest outputFormat.WriteMediaTag(buffer, mediaTag); } - Assert.IsTrue(outputFormat.SetTracks(inputFormat.Tracks), - string.Format(Localization.Error_0_sending_tracks_list_to_output_image, - outputFormat.ErrorMessage)); + Assert.That(outputFormat.SetTracks(inputFormat.Tracks), + string.Format(Localization.Error_0_sending_tracks_list_to_output_image, + outputFormat.ErrorMessage)); ulong doneSectors; @@ -265,7 +272,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest sectorsToDo, out sector); - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); result = sectorsToDo == 1 ? outputFormat.WriteSector(sector, doneSectors + track.StartSector) @@ -274,10 +281,10 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest sectorsToDo); } - Assert.IsTrue(result, - string.Format(Localization.Error_0_writing_sector_1, - outputFormat.ErrorMessage, - doneSectors + track.StartSector)); + Assert.That(result, + string.Format(Localization.Error_0_writing_sector_1, + outputFormat.ErrorMessage, + doneSectors + track.StartSector)); doneSectors += sectorsToDo; } @@ -378,15 +385,15 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest case SectorTagType.CdTrackIsrc: errno = inputFormat.ReadSectorTag(track.Sequence, tag, out sector); - Assert.AreEqual(ErrorNumber.NoError, - errno, - string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); + Assert.That(errno, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); result = outputFormat.WriteSectorTag(sector, track.Sequence, tag); - Assert.IsTrue(result, - string.Format(Localization.Error_0_writing_tag_not_continuing, - outputFormat.ErrorMessage)); + Assert.That(result, + string.Format(Localization.Error_0_writing_tag_not_continuing, + outputFormat.ErrorMessage)); continue; } @@ -404,9 +411,9 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector); - Assert.AreEqual(ErrorNumber.NoError, - errno, - string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); + Assert.That(errno, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); if(tag == SectorTagType.CdSectorSubchannel) { @@ -445,9 +452,9 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest tag, out sector); - Assert.AreEqual(ErrorNumber.NoError, - errno, - string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); + Assert.That(errno, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); if(tag == SectorTagType.CdSectorSubchannel) { @@ -485,10 +492,10 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest } } - Assert.IsTrue(result, - string.Format(Localization.Error_0_writing_tag_for_sector_1_not_continuing, - outputFormat.ErrorMessage, - doneSectors + track.StartSector)); + Assert.That(result, + string.Format(Localization.Error_0_writing_tag_for_sector_1_not_continuing, + outputFormat.ErrorMessage, + doneSectors + track.StartSector)); doneSectors += sectorsToDo; } @@ -506,8 +513,10 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest } if(trackFlags.Count > 0) + { foreach((byte track, byte flags) in trackFlags) outputFormat.WriteSectorTag([flags], track, SectorTagType.CdTrackFlags); + } if(mcn != null) outputFormat.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); @@ -565,9 +574,9 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest outputFormat); } - Assert.IsTrue(outputFormat.Close(), - string.Format(Localization.Error_0_closing_output_image_Contents_are_not_correct, - outputFormat.ErrorMessage)); + Assert.That(outputFormat.Close(), + string.Format(Localization.Error_0_closing_output_image_Contents_are_not_correct, + outputFormat.ErrorMessage)); filter = PluginRegister.Singleton.GetFilter(outputPath); filter.Open(outputPath); @@ -576,10 +585,16 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest Environment.CurrentDirectory = tmpFolder; var image = Activator.CreateInstance(OutputPlugin.GetType()) as IOpticalMediaImage; - Assert.NotNull(image, string.Format(Localization.Could_not_instantiate_output_plugin_for_0, testFile)); + + Assert.That(image, + Is.Not.Null, + string.Format(Localization.Could_not_instantiate_output_plugin_for_0, testFile)); opened = image.Open(filter); - Assert.AreEqual(ErrorNumber.NoError, opened, string.Format(Localization.Open_created_0, testFile)); + + Assert.That(opened, + Is.EqualTo(ErrorNumber.NoError), + string.Format(Localization.Open_created_0, testFile)); if(opened != ErrorNumber.NoError) continue; @@ -587,20 +602,20 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { Assert.Multiple(() => { - Assert.AreEqual(test.Sectors, - image.Info.Sectors, - string.Format(Localization.Sectors_output_0, testFile)); + Assert.That(image.Info.Sectors, + Is.EqualTo(test.Sectors), + string.Format(Localization.Sectors_output_0, testFile)); if(test.SectorSize > 0) { - Assert.AreEqual(test.SectorSize, - image.Info.SectorSize, - string.Format(Localization.Sector_size_output_0, testFile)); + Assert.That(image.Info.SectorSize, + Is.EqualTo(test.SectorSize), + string.Format(Localization.Sector_size_output_0, testFile)); } - Assert.AreEqual(test.Tracks.Length, - image.Tracks.Count, - string.Format(Localization.Tracks_output_0, testFile)); + Assert.That(image.Tracks, + Has.Count.EqualTo(test.Tracks.Length), + string.Format(Localization.Tracks_output_0, testFile)); image.Tracks.Select(t => t.Session) .Should() @@ -647,12 +662,11 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest .BeEquivalentTo(test.Tracks.Select(s => s.Flags), string.Format(Localization.Track_flags_output_0, testFile)); - Assert.AreEqual(latestEndSector, - image.Info.Sectors - 1, - string.Format(Localization - .Last_sector_for_tracks_is_0_but_it_is_1_for_image_output, - latestEndSector, - image.Info.Sectors)); + Assert.That(image.Info.Sectors - 1, + Is.EqualTo(latestEndSector), + string.Format(Localization.Last_sector_for_tracks_is_0_but_it_is_1_for_image_output, + latestEndSector, + image.Info.Sectors)); }); } @@ -703,17 +717,17 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest doneSectors += sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } } - Assert.AreEqual(@long ? test.LongMd5 : test.Md5, - ctx.End(), - string.Format("{0}: {1}", - @long ? Localization.Long_hash_output : Localization.Hash_output, - testFile)); + Assert.That(ctx.End(), + Is.EqualTo(@long ? test.LongMd5 : test.Md5), + string.Format("{0}: {1}", + @long ? Localization.Long_hash_output : Localization.Hash_output, + testFile)); } if(!image.Info.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) return; @@ -750,15 +764,15 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest doneSectors += sectors - doneSectors; } - Assert.AreEqual(ErrorNumber.NoError, errno); + Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); ctx.Update(sector); } } - Assert.AreEqual(test.SubchannelMd5, - ctx.End(), - string.Format(Localization.Subchannel_hash_output_0, testFile)); + Assert.That(ctx.End(), + Is.EqualTo(test.SubchannelMd5), + string.Format(Localization.Subchannel_hash_output_0, testFile)); } }); } diff --git a/Aaru.sln.DotSettings b/Aaru.sln.DotSettings index 1c2be982a..00229cf4e 100644 --- a/Aaru.sln.DotSettings +++ b/Aaru.sln.DotSettings @@ -343,6 +343,51 @@ WARNING WARNING SUGGESTION + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + WARNING + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + ERROR + WARNING + ERROR + ERROR + ERROR + ERROR RequiredForMultiline RequiredForMultiline RequiredForMultiline