mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Make image format tests inherit a single class.
This commit is contained in:
@@ -26,27 +26,24 @@
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Aaru.Checksums;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.DiscImages;
|
||||
using Aaru.Filters;
|
||||
using FluentAssertions.Execution;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Aaru.Tests.Images.Lisa
|
||||
{
|
||||
[TestFixture]
|
||||
public class Raw
|
||||
public class Raw : BlockMediaImageTest
|
||||
{
|
||||
readonly string[] _testFiles =
|
||||
public override string[] _testFiles => new[]
|
||||
{
|
||||
"profile_los202.raw.lz", "profile_los31.raw.lz", "profile_macworksxl3.raw.lz", "profile_uniplus.raw.lz",
|
||||
"profile_xenix_10Mb.raw.lz", "profile_xenix.raw.lz"
|
||||
};
|
||||
|
||||
readonly ulong[] _sectors =
|
||||
public override ulong[] _sectors => new ulong[]
|
||||
{
|
||||
// profile_los202.raw.lz
|
||||
10108,
|
||||
@@ -67,7 +64,7 @@ namespace Aaru.Tests.Images.Lisa
|
||||
10108
|
||||
};
|
||||
|
||||
readonly uint[] _sectorSize =
|
||||
public override uint[] _sectorSize => new uint[]
|
||||
{
|
||||
// profile_los202.raw.lz
|
||||
512,
|
||||
@@ -88,7 +85,7 @@ namespace Aaru.Tests.Images.Lisa
|
||||
512
|
||||
};
|
||||
|
||||
readonly MediaType[] _mediaTypes =
|
||||
public override MediaType[] _mediaTypes => new[]
|
||||
{
|
||||
// profile_los202.raw.lz
|
||||
MediaType.GENERIC_HDD,
|
||||
@@ -109,7 +106,7 @@ namespace Aaru.Tests.Images.Lisa
|
||||
MediaType.GENERIC_HDD
|
||||
};
|
||||
|
||||
readonly string[] _md5S =
|
||||
public override string[] _md5S => new[]
|
||||
{
|
||||
// profile_los202.raw.lz
|
||||
"24001116ee48e6545e4514b3ea18b4e2",
|
||||
@@ -130,89 +127,8 @@ namespace Aaru.Tests.Images.Lisa
|
||||
"dd146bc14be87d5ad98b961dd462f469"
|
||||
};
|
||||
|
||||
readonly string _dataFolder =
|
||||
public override string _dataFolder =>
|
||||
Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "Lisa emulators", "raw");
|
||||
|
||||
[Test]
|
||||
public void Info()
|
||||
{
|
||||
Environment.CurrentDirectory = _dataFolder;
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
for(int i = 0; i < _testFiles.Length; i++)
|
||||
{
|
||||
var filter = new LZip();
|
||||
filter.Open(_testFiles[i]);
|
||||
|
||||
var image = new ZZZRawImage();
|
||||
bool opened = image.Open(filter);
|
||||
|
||||
Assert.AreEqual(true, opened, $"Open: {_testFiles[i]}");
|
||||
|
||||
if(!opened)
|
||||
continue;
|
||||
|
||||
using(new AssertionScope())
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.AreEqual(_sectors[i], image.Info.Sectors, $"Sectors: {_testFiles[i]}");
|
||||
Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, $"Sector size: {_testFiles[i]}");
|
||||
Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, $"Media type: {_testFiles[i]}");
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// How many sectors to read at once
|
||||
const uint SECTORS_TO_READ = 256;
|
||||
|
||||
[Test]
|
||||
public void Hashes()
|
||||
{
|
||||
Environment.CurrentDirectory = _dataFolder;
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
for(int i = 0; i < _testFiles.Length; i++)
|
||||
{
|
||||
var filter = new LZip();
|
||||
filter.Open(_testFiles[i]);
|
||||
|
||||
var image = new ZZZRawImage();
|
||||
bool opened = image.Open(filter);
|
||||
ulong doneSectors = 0;
|
||||
|
||||
Assert.AreEqual(true, opened, $"Open: {_testFiles[i]}");
|
||||
|
||||
if(!opened)
|
||||
continue;
|
||||
|
||||
var ctx = new Md5Context();
|
||||
|
||||
while(doneSectors < image.Info.Sectors)
|
||||
{
|
||||
byte[] sector;
|
||||
|
||||
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
|
||||
{
|
||||
sector = image.ReadSectors(doneSectors, SECTORS_TO_READ);
|
||||
doneSectors += SECTORS_TO_READ;
|
||||
}
|
||||
else
|
||||
{
|
||||
sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
|
||||
doneSectors += image.Info.Sectors - doneSectors;
|
||||
}
|
||||
|
||||
ctx.Update(sector);
|
||||
}
|
||||
|
||||
Assert.AreEqual(_md5S[i], ctx.End(), $"Hash: {_testFiles[i]}");
|
||||
}
|
||||
});
|
||||
}
|
||||
public override IMediaImage _plugin => new ZZZRawImage();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user