mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
🎨Remove chains of if-else to get media type from it's geometry, plus add
a geometry class with a list of known geometries and ❤️LINQ❤️ queries.
This commit is contained in:
@@ -51,8 +51,8 @@ namespace DiscImageChef.Tests.Images
|
||||
// TODO: Add "unknown" media types
|
||||
readonly MediaType[] mediatypes =
|
||||
{
|
||||
MediaType.DOS_35_DS_DD_9, MediaType.Unknown, MediaType.Unknown, MediaType.DOS_35_HD, MediaType.DOS_35_HD,
|
||||
MediaType.DMF, MediaType.DMF
|
||||
MediaType.DOS_35_DS_DD_9, MediaType.CBM_35_DD, MediaType.CBM_35_DD, MediaType.DOS_35_HD,
|
||||
MediaType.DOS_35_HD, MediaType.DMF, MediaType.DMF
|
||||
};
|
||||
|
||||
readonly string[] md5S =
|
||||
@@ -67,18 +67,18 @@ namespace DiscImageChef.Tests.Images
|
||||
{
|
||||
for(int i = 0; i < testfiles.Length; i++)
|
||||
{
|
||||
string location = Path.Combine(Consts.TestFilesRoot, "images", "copyqm", testfiles[i]);
|
||||
IFilter filter = new LZip();
|
||||
string location = Path.Combine(Consts.TestFilesRoot, "images", "copyqm", testfiles[i]);
|
||||
IFilter filter = new LZip();
|
||||
filter.Open(location);
|
||||
IMediaImage image = new DiscImages.CopyQm();
|
||||
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
|
||||
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
|
||||
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
|
||||
Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
|
||||
Assert.AreEqual(true, image.OpenImage(filter), testfiles[i]);
|
||||
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
|
||||
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
|
||||
Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]);
|
||||
|
||||
// How many sectors to read at once
|
||||
const uint SECTORS_TO_READ = 256;
|
||||
ulong doneSectors = 0;
|
||||
ulong doneSectors = 0;
|
||||
|
||||
Md5Context ctx = new Md5Context();
|
||||
ctx.Init();
|
||||
@@ -89,13 +89,13 @@ namespace DiscImageChef.Tests.Images
|
||||
|
||||
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
|
||||
{
|
||||
sector = image.ReadSectors(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;
|
||||
sector = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors));
|
||||
doneSectors += image.Info.Sectors - doneSectors;
|
||||
}
|
||||
|
||||
ctx.Update(sector);
|
||||
|
||||
Reference in New Issue
Block a user