[DataRow("1234", "5678", 0)] // Diff eveywhere public void IContinuousCorrelaterTest_InnerCorrelaterIsContinuous(string string1, string string2, int extraTimesToCallOrResultUpdate) { var levenshteinCorrelater = new LevenshteinCorrelater <char>(missmatchCost, removalInsertionCost, removalInsertionCost); var splitToChunksCorrelater = new SplitToChunksCorrelaterWrapper <char>(levenshteinCorrelater, 2); var correlater = new IgnoreIdenticalBeginningAndEndCorrelaterWrapper <char>(splitToChunksCorrelater); var match1 = new List <char>(); var match2 = new List <char>(); var totalDistance = 0L; var totalUpdates = 0; var innerUpdates = 0; correlater.OnResultUpdate += result => { match1.AddRange(result.BestMatch1); match2.AddRange(result.BestMatch2); totalDistance += result.Distance; totalUpdates++; }; splitToChunksCorrelater.OnResultUpdate += _ => innerUpdates++; var actualResult = correlater.Correlate(string1, string2); var resultFromEvent = new CorrelaterResult <char>(totalDistance, match1.ToArray(), match2.ToArray()); Assertions.AssertResultIsAsExpected(actualResult, resultFromEvent); Assert.AreEqual(extraTimesToCallOrResultUpdate + innerUpdates, totalUpdates, $"Got wrong number of {nameof(totalUpdates)}"); }
[DataRow("1234", "5678", 1)] // Diff eveywhere public void IContinuousCorrelaterTest_InnerCorrelaterNotContinuous(string string1, string string2, int timeToCallOrResultUpdate) { A.CallTo(() => innerCorrelater.Correlate(A <IEnumerable <char> > ._, A <IEnumerable <char> > ._, A <CancellationToken> ._)). Returns(new CorrelaterResult <char>(10, "123\04".ToArray(), "5678\0".ToArray())); var match1 = new List <char>(); var match2 = new List <char>(); var totalDistance = 0L; var totalUpdates = 0; correlater.OnResultUpdate += result => { match1.AddRange(result.BestMatch1); match2.AddRange(result.BestMatch2); totalDistance += result.Distance; totalUpdates++; }; var actualResult = correlater.Correlate(string1, string2); var resultFromEvent = new CorrelaterResult <char>(totalDistance, match1.ToArray(), match2.ToArray()); Assertions.AssertResultIsAsExpected(actualResult, resultFromEvent); Assert.AreEqual(timeToCallOrResultUpdate, totalUpdates, $"Got wrong number of {nameof(totalUpdates)}"); }