public void Test() { Environment.CurrentDirectory = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "UltraISO", "Alcohol"); for (int i = 0; i < _testFiles.Length; i++) { var filter = new ZZZNoFilter(); filter.Open(_testFiles[i]); var image = new DiscImages.Alcohol120(); bool opened = image.Open(filter); Assert.AreEqual(true, opened, $"Open: {_testFiles[i]}"); using (new AssertionScope()) { Assert.Multiple(() => { Assert.AreEqual(_sectors[i], image.Info.Sectors, $"Sectors: {_testFiles[i]}"); Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, $"Media type: {_testFiles[i]}"); Assert.AreEqual(_tracks[i], image.Tracks.Count, $"Tracks: {_testFiles[i]}"); image.Tracks.Select(t => t.TrackSession).Should(). BeEquivalentTo(_trackSessions[i], $"Track session: {_testFiles[i]}"); image.Tracks.Select(t => t.TrackStartSector).Should(). BeEquivalentTo(_trackStarts[i], $"Track start: {_testFiles[i]}"); image.Tracks.Select(t => t.TrackEndSector).Should(). BeEquivalentTo(_trackEnds[i], $"Track end: {_testFiles[i]}"); image.Tracks.Select(t => t.TrackPregap).Should(). BeEquivalentTo(_trackPregaps[i], $"Track pregap: {_testFiles[i]}"); int trackNo = 0; byte[] flags = new byte[image.Tracks.Count]; foreach (Track currentTrack in image.Tracks) { if (image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags)) { flags[trackNo] = image.ReadSectorTag(currentTrack.TrackSequence, SectorTagType.CdTrackFlags)[0]; } trackNo++; } flags.Should().BeEquivalentTo(_trackFlags[i], $"Track flags: {_testFiles[i]}"); }); } } }
public void Test() { Environment.CurrentDirectory = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "Alcohol 120%"); for (int i = 0; i < _testFiles.Length; i++) { IFilter filter = new ZZZNoFilter(); filter.Open(_testFiles[i]); IOpticalMediaImage image = new DiscImages.Alcohol120(); Assert.AreEqual(true, image.Open(filter), _testFiles[i]); Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]); Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, _testFiles[i]); Assert.AreEqual(_tracks[i], image.Tracks.Count, _testFiles[i]); // How many sectors to read at once const uint sectorsToRead = 256; int trackNo = 0; foreach (Track currentTrack in image.Tracks) { Assert.AreEqual(_trackSessions[i][trackNo], currentTrack.TrackSession, _testFiles[i]); Assert.AreEqual(_trackStarts[i][trackNo], currentTrack.TrackStartSector, _testFiles[i]); Assert.AreEqual(_trackEnds[i][trackNo], currentTrack.TrackEndSector, _testFiles[i]); Assert.AreEqual(_trackPregaps[i][trackNo], currentTrack.TrackPregap, _testFiles[i]); if (image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags)) { Assert.AreEqual(_trackFlags[i][trackNo], image.ReadSectorTag(currentTrack.TrackSequence, SectorTagType.CdTrackFlags)[0], _testFiles[i]); } trackNo++; } foreach (bool @long in new[] { false, true }) { var ctx = new Md5Context(); foreach (Track currentTrack in image.Tracks) { ulong sectors = (currentTrack.TrackEndSector - currentTrack.TrackStartSector) + 1; ulong doneSectors = 0; while (doneSectors < sectors) { byte[] sector; if (sectors - doneSectors >= sectorsToRead) { sector = @long ? image.ReadSectorsLong(doneSectors, sectorsToRead, currentTrack.TrackSequence) : image.ReadSectors(doneSectors, sectorsToRead, currentTrack.TrackSequence); doneSectors += sectorsToRead; } else { sector = @long ? image.ReadSectorsLong(doneSectors, (uint)(sectors - doneSectors), currentTrack.TrackSequence) : image.ReadSectors(doneSectors, (uint)(sectors - doneSectors), currentTrack.TrackSequence); doneSectors += sectors - doneSectors; } ctx.Update(sector); } } Assert.AreEqual(@long ? _longMd5S[i] : _md5S[i], ctx.End(), _testFiles[i]); } if (image.Info.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) { var ctx = new Md5Context(); foreach (Track currentTrack in image.Tracks) { ulong sectors = (currentTrack.TrackEndSector - currentTrack.TrackStartSector) + 1; ulong doneSectors = 0; while (doneSectors < sectors) { byte[] sector; if (sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectorsTag(doneSectors, sectorsToRead, currentTrack.TrackSequence, SectorTagType.CdSectorSubchannel); doneSectors += sectorsToRead; } else { sector = image.ReadSectorsTag(doneSectors, (uint)(sectors - doneSectors), currentTrack.TrackSequence, SectorTagType.CdSectorSubchannel); doneSectors += sectors - doneSectors; } ctx.Update(sector); } } Assert.AreEqual(_subchannelMd5S[i], ctx.End(), _testFiles[i]); } } }