public void AddExistingResultTest() { //given var duplicateResultFull = GetGivenResult(); var fileLine1 = new FileLine("1.txt", "aaa", 100, 1); fileLine1.AddResult(1); var fileLine2 = new FileLine("1.txt", "aaa", 200, 1); //when duplicateResultFull.Add(20, fileLine1, fileLine2); //then Assert.That(duplicateResultFull.Count, Is.EqualTo(2)); Assert.That(duplicateResultFull[0].GetUnitsCount(), Is.EqualTo(3)); Assert.That(duplicateResultFull[1].GetUnitsCount(), Is.EqualTo(3)); }
public void AddPartiallyNewResultTest() { //given var duplicateResultFull = GetGivenResult(); var fileLine1 = new FileLine("1.txt", "aaa", 10, 1); fileLine1.AddResult(0); var fileLine2 = new FileLine("4.txt", "aaa", 60, 1); //when duplicateResultFull.Add(5, fileLine1, fileLine2); //then Assert.That(duplicateResultFull.Count, Is.EqualTo(2)); Assert.That(duplicateResultFull[0].GetUnitsCount(), Is.EqualTo(4)); Assert.That(duplicateResultFull[0].GetUnit(3).FileName, Is.EqualTo("4.txt")); Assert.That(duplicateResultFull[0].GetUnit(3).LineNumber, Is.EqualTo(60)); Assert.That(duplicateResultFull[1].GetUnitsCount(), Is.EqualTo(3)); Assert.IsTrue(fileLine2.IsIncludedInResult(0)); }
public void Add(int numberOfLines, FileLine fileLine1, FileLine fileLine2) { var duplicateResultIndex = GetExistingResultIndex(numberOfLines, fileLine1); DuplicateResult duplicateResult; if (duplicateResultIndex == -1) { duplicateResult = new DuplicateResult(numberOfLines); duplicateResult.AddUnit(fileLine1.FileName, fileLine1.LineNumber); duplicateResult.AddUnit(fileLine2.FileName, fileLine2.LineNumber); Add(duplicateResult); duplicateResultIndex = Count - 1; } else { duplicateResult = _results[duplicateResultIndex]; if (!duplicateResult.IsIncludedInThisResult(numberOfLines, fileLine2.FileName, fileLine2.LineNumber)) { duplicateResult.AddUnit(fileLine2.FileName, fileLine2.LineNumber); } } fileLine1.AddResult(duplicateResultIndex); fileLine2.AddResult(duplicateResultIndex); }