public void DeleteHashBinsAndSubfingerprintsOnTrackDelete()
        {
            const int StaticStride = 5115;
            const int SecondsToProcess = 20;
            const int StartAtSecond = 30;
            DefaultQueryConfiguration defaultQueryConfiguration = new DefaultQueryConfiguration();
            TagInfo tagInfo = tagService.GetTagInfo(PathToMp3);
            int releaseYear = tagInfo.Year;
            Track track = new Track(tagInfo.ISRC, tagInfo.Artist, tagInfo.Title, tagInfo.Album, releaseYear, (int)tagInfo.Duration);
            modelService.InsertTrack(track);

            var subFingerprints = fingerprintUnitBuilder.BuildAudioFingerprintingUnit()
                                            .From(PathToMp3, SecondsToProcess, StartAtSecond)
                                            .WithCustomAlgorithmConfiguration(config =>
                                            {
                                                config.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint);
                                            })
                                            .FingerprintIt()
                                            .HashIt()
                                            .ForTrack(track.Id)
                                            .Result;

            modelService.InsertSubFingerprint(subFingerprints);
            var hashBins = new List<HashBinMinHash>();
            foreach (var subFingerprint in subFingerprints)
            {
                long[] groupedSubFingerprint = lshService.Hash(subFingerprint.Signature, defaultQueryConfiguration.NumberOfLSHTables, defaultQueryConfiguration.NumberOfMinHashesPerTable);
                for (int i = 0; i < groupedSubFingerprint.Length; i++)
                {
                    int tableNumber = i + 1;
                    hashBins.Add(new HashBinMinHash(groupedSubFingerprint[i], tableNumber, subFingerprint.Id));
                }
            }

            modelService.InsertHashBin(hashBins);
            var actualTrack = modelService.ReadTrackByISRC(tagInfo.ISRC);
            Assert.IsNotNull(actualTrack);
            AssertTracksAreEqual(track, actualTrack);
            foreach (var subFingerprint in subFingerprints)
            {
                long[] groupedSubFingerprint = lshService.Hash(subFingerprint.Signature, defaultQueryConfiguration.NumberOfLSHTables, defaultQueryConfiguration.NumberOfMinHashesPerTable);
                var result = modelService.ReadSubFingerprintsByHashBucketsHavingThreshold(groupedSubFingerprint, defaultQueryConfiguration.NumberOfLSHTables);
                var tupple = result.First();
                Assert.AreEqual(defaultQueryConfiguration.NumberOfLSHTables, tupple.Item2);
                var actualSufingerprint = tupple.Item1;
                AssertSubFingerprintsAreEqual(subFingerprint, actualSufingerprint);
            }

            // Act
            modelService.DeleteTrack(track);

            Assert.IsNull(modelService.ReadTrackByISRC(tagInfo.ISRC));
            foreach (var subFingerprint in subFingerprints)
            {
                long[] groupedSubFingerprint = lshService.Hash(subFingerprint.Signature, defaultQueryConfiguration.NumberOfLSHTables, defaultQueryConfiguration.NumberOfMinHashesPerTable);
                var result = modelService.ReadSubFingerprintsByHashBucketsHavingThreshold(groupedSubFingerprint, defaultQueryConfiguration.NumberOfLSHTables);
                Assert.IsTrue(!result.Any());
            }
        }
        public void CreateFingerprintsInsertThenQueryAndGetTheRightResult()
        {
            const int StaticStride = 5115;
            const int SecondsToProcess = 10;
            const int StartAtSecond = 30;
            DefaultQueryConfiguration defaultQueryConfiguration = new DefaultQueryConfiguration();
            QueryFingerprintService queryFingerprintService = new QueryFingerprintService(new CombinedHashingAlgorithm(), modelService);
            ITagService tagService = new BassAudioService();
            TagInfo info = tagService.GetTagInfo(PathToMp3);
            int releaseYear = info.Year;
            Track track = new Track(info.ISRC, info.Artist, info.Title, info.Album, releaseYear, (int)info.Duration);

            modelService.InsertTrack(track);

            var fingerprinter = fingerprintUnitBuilderWithBass.BuildAudioFingerprintingUnit()
                                            .From(PathToMp3, SecondsToProcess, StartAtSecond)
                                            .WithCustomAlgorithmConfiguration(config =>
                                            {
                                                config.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint);
                                            })
                                            .FingerprintIt();

            var fingerprints = fingerprinter.AsIs().Result;
            var subFingerprints = fingerprinter.HashIt().ForTrack(track.Id).Result;

            modelService.InsertSubFingerprint(subFingerprints);

            List<HashBinMinHash> hashBins = new List<HashBinMinHash>();
            foreach (SubFingerprint subFingerprint in subFingerprints)
            {
                long[] groupedSubFingerprint = lshService.Hash(subFingerprint.Signature, defaultQueryConfiguration.NumberOfLSHTables, defaultQueryConfiguration.NumberOfMinHashesPerTable);
                for (int i = 0; i < groupedSubFingerprint.Length; i++)
                {
                    int tableNumber = i + 1;
                    hashBins.Add(new HashBinMinHash(groupedSubFingerprint[i], tableNumber, subFingerprint.Id));
                }
            }

            modelService.InsertHashBin(hashBins);

            QueryResult result = queryFingerprintService.Query(fingerprints, defaultQueryConfiguration);

            Assert.IsTrue(result.IsSuccessful);
            Assert.AreEqual(track.Id, result.Results[0].Track.Id);
        }