public void InsertTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); int trackId = TrackDao.Insert(track); long subFingerprintId = SubFingerprintDao.Insert(GenericSignature, trackId); Assert.IsFalse(subFingerprintId == 0); }
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); int trackId = TrackDao.Insert(track); var hashData = fingerprintCommandBuilder .BuildFingerprintCommand() .From(PathToMp3, SecondsToProcess, StartAtSecond) .WithFingerprintConfig(config => { config.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint); }) .Hash() .Result; List <long> subFingerprintIds = new List <long>(); foreach (var hash in hashData) { long subFingerprintId = SubFingerprintDao.Insert(hash.SubFingerprint, trackId); HashBinDao.Insert(hash.HashBins, subFingerprintId); subFingerprintIds.Add(subFingerprintId); } var actualTrack = TrackDao.ReadTrackByISRC(tagInfo.ISRC); Assert.IsNotNull(actualTrack); AssertTracksAreEqual(track, actualTrack); // Act int modifiedRows = TrackDao.DeleteTrack(trackId); Assert.IsNull(TrackDao.ReadTrackByISRC(tagInfo.ISRC)); foreach (var id in subFingerprintIds) { Assert.IsTrue(id != 0); Assert.IsNull(SubFingerprintDao.ReadById(id)); } for (int i = 1; i <= 25; i++) { Assert.IsTrue(HashBinDao.ReadHashBinsByHashTable(i).Count == 0); } Assert.AreEqual(1 + hashData.Count + (25 * hashData.Count), modifiedRows); }
public void ReadTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); int trackId = TrackDao.Insert(track); long subFingerprintId = SubFingerprintDao.Insert(GenericSignature, trackId); SubFingerprintData actual = SubFingerprintDao.ReadById(subFingerprintId); AsserSubFingerprintsAreEqual( new SubFingerprintData( GenericSignature, new ModelReference <long>(subFingerprintId), new ModelReference <int>(trackId)), actual); }