public void Will_return_correct_two_item_list_for_strings_with_multiple_difference_non_consecutively() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("z a b c d ", "x v a b e f g h ", false, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(4, res.DiffBlocks.Count); Assert.Equal(0, res.DiffBlocks[0].DeleteStartA); Assert.Equal(1, res.DiffBlocks[0].DeleteCountA); Assert.Equal(0, res.DiffBlocks[0].InsertStartB); Assert.Equal(3, res.DiffBlocks[0].InsertCountB); Assert.Equal(5, res.DiffBlocks[1].DeleteStartA); Assert.Equal(0, res.DiffBlocks[1].DeleteCountA); Assert.Equal(7, res.DiffBlocks[1].InsertStartB); Assert.Equal(4, res.DiffBlocks[1].InsertCountB); Assert.Equal(6, res.DiffBlocks[2].DeleteStartA); Assert.Equal(1, res.DiffBlocks[2].DeleteCountA); Assert.Equal(12, res.DiffBlocks[2].InsertStartB); Assert.Equal(1, res.DiffBlocks[2].InsertCountB); Assert.Equal(8, res.DiffBlocks[3].DeleteStartA); Assert.Equal(1, res.DiffBlocks[3].DeleteCountA); Assert.Equal(14, res.DiffBlocks[3].InsertStartB); Assert.Equal(1, res.DiffBlocks[3].InsertCountB); }
public void Will_ignore_case_when_ignore_case_is_true() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("z a", "Z A", false, true, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(0, res.DiffBlocks.Count); }
public void Will_throw_if_newText_is_null() { var differ = new TestableDiffer(); var ex = Record.Exception(() => differ.CreateWordDiffs("someString", null, false, new[] { ' ' })) as ArgumentNullException; Assert.NotNull(ex); Assert.Equal("newText", ex.ParamName); }
public void Will_return_list_of_length_zero_if_there_are_no_differences() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("abc defg", "abc defg", false, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(0, res.DiffBlocks.Count); }
public void Will_return_correct_one_item_list_when_no_insertions() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("ab d ce", "ab ce", false, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(1, res.DiffBlocks.Count); Assert.Equal(1, res.DiffBlocks[0].DeleteStartA); Assert.Equal(1, res.DiffBlocks[0].DeleteCountA); Assert.Equal(0, res.DiffBlocks[0].InsertCountB); }
public void Will_return_correct_one_item_list_for_strings_with_one_difference() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("x j zwv", "x y zwv", false, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(1, res.DiffBlocks.Count); Assert.Equal(2, res.DiffBlocks[0].DeleteStartA); Assert.Equal(1, res.DiffBlocks[0].DeleteCountA); Assert.Equal(2, res.DiffBlocks[0].InsertStartB); Assert.Equal(1, res.DiffBlocks[0].InsertCountB); }
public void Will_return_correct_diff_block_when_newText_is_empty_and_oldText_is_non_empty() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("xy w", "", false, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(1, res.DiffBlocks.Count); Assert.Equal(0, res.DiffBlocks[0].DeleteStartA); Assert.Equal(3, res.DiffBlocks[0].DeleteCountA); Assert.Equal(0, res.DiffBlocks[0].InsertStartB); Assert.Equal(0, res.DiffBlocks[0].InsertCountB); }
public void Will_return_correct_diff_for_different_separators() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs(string.Format("z{0}a{0}b{0}c{0}d{0}{0}", ' '), string.Format("x{0}v{0}a{0}b{0}e{0}f{0}g{0}h{0}{0}", ';'), false, new[] { ' ', ';' }); Assert.NotNull(res); Assert.Equal(1, res.DiffBlocks.Count); Assert.Equal(0, res.DiffBlocks[0].DeleteStartA); Assert.Equal(6, res.DiffBlocks[0].DeleteCountA); Assert.Equal(0, res.DiffBlocks[0].InsertStartB); Assert.Equal(9, res.DiffBlocks[0].InsertCountB); }
public void Will_return_correct_diff_for_multiple_chained_separators_ending_with_char() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("z a b", "z ab", false, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(1, res.DiffBlocks.Count); Assert.Equal(2, res.DiffBlocks[0].DeleteStartA); Assert.Equal(3, res.DiffBlocks[0].DeleteCountA); Assert.Equal(2, res.DiffBlocks[0].InsertStartB); Assert.Equal(1, res.DiffBlocks[0].InsertCountB); }
public void Will_return_correct_diff_for_arbitrary_separators(char separator) { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs(string.Format("z{0}a{0}{0}", separator), string.Format("z{0}v{0}{0}", separator), false, new[] { separator }); Assert.NotNull(res); Assert.Equal(1, res.DiffBlocks.Count); Assert.Equal(2, res.DiffBlocks[0].DeleteStartA); Assert.Equal(1, res.DiffBlocks[0].DeleteCountA); Assert.Equal(2, res.DiffBlocks[0].InsertStartB); Assert.Equal(1, res.DiffBlocks[0].InsertCountB); }
public void Will_return_correct_diff_for_when_multiple_letters_in_the_end() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("one line", "second line", false, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(1, res.DiffBlocks.Count); Assert.Equal(res.PiecesOld, new List <string>() { "one", " ", "line" }); Assert.Equal(res.PiecesNew, new List <string>() { "second", " ", "line" }); }
public void Will_ignore_case_when_ignore_case_is_true() { var differ = new TestableDiffer(); var res = differ.CreateWordDiffs("z a b c d ", "X V A B E F G H ", false, true, new[] { ' ' }); Assert.NotNull(res); Assert.Equal(2, res.DiffBlocks.Count); Assert.Equal(0, res.DiffBlocks[0].DeleteStartA); Assert.Equal(1, res.DiffBlocks[0].DeleteCountA); Assert.Equal(0, res.DiffBlocks[0].InsertStartB); Assert.Equal(2, res.DiffBlocks[0].InsertCountB); Assert.Equal(3, res.DiffBlocks[1].DeleteStartA); Assert.Equal(2, res.DiffBlocks[1].DeleteCountA); Assert.Equal(4, res.DiffBlocks[1].InsertStartB); Assert.Equal(4, res.DiffBlocks[1].InsertCountB); }