public void ReadTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = TrackDao.InsertTrack(track); var subFingerprintReference = SubFingerprintDao.InsertSubFingerprint(GenericSignature, trackReference); SubFingerprintData actual = SubFingerprintDao.ReadSubFingerprint(subFingerprintReference); AsserSubFingerprintsAreEqual(new SubFingerprintData(GenericSignature, subFingerprintReference, trackReference), actual); }
public void DeleteHashBinsAndSubfingerprintsOnTrackDelete() { const int StaticStride = 5115; const int SecondsToProcess = 20; const int StartAtSecond = 30; TagInfo tagInfo = tagService.GetTagInfo(PathToMp3); int releaseYear = tagInfo.Year; TrackData track = new TrackData(tagInfo.ISRC, tagInfo.Artist, tagInfo.Title, tagInfo.Album, releaseYear, (int)tagInfo.Duration); var trackReference = TrackDao.InsertTrack(track); var hashData = fingerprintCommandBuilder .BuildFingerprintCommand() .From(PathToMp3, SecondsToProcess, StartAtSecond) .WithFingerprintConfig(config => { config.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint); }) .UsingServices(audioService) .Hash() .Result; var subFingerprintReferences = new List <IModelReference>(); foreach (var hash in hashData) { var subFingerprintReference = SubFingerprintDao.InsertSubFingerprint(hash.SubFingerprint, trackReference); HashBinDao.InsertHashBins(hash.HashBins, subFingerprintReference, trackReference); subFingerprintReferences.Add(subFingerprintReference); } var actualTrack = TrackDao.ReadTrackByISRC(tagInfo.ISRC); Assert.IsNotNull(actualTrack); AssertTracksAreEqual(track, actualTrack); // Act int modifiedRows = TrackDao.DeleteTrack(trackReference); Assert.IsNull(TrackDao.ReadTrackByISRC(tagInfo.ISRC)); foreach (var id in subFingerprintReferences) { Assert.IsTrue(id.GetHashCode() != 0); Assert.IsNull(SubFingerprintDao.ReadSubFingerprint(id)); } Assert.IsTrue(HashBinDao.ReadHashDataByTrackReference(actualTrack.TrackReference).Count == 0); Assert.AreEqual(1 + hashData.Count + (25 * hashData.Count), modifiedRows); }