Beispiel #1
0
            public void Will_return_list_of_length_zero_if_there_are_no_differences()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateCharacterDiffs("abc defg", "abc defg", false);

                Assert.NotNull(res);
                Assert.Equal(0, res.DiffBlocks.Count);
            }
Beispiel #2
0
            public void Will_throw_if_newText_is_null()
            {
                var differ = new TestableDiffer();

                var ex = Record.Exception(() => differ.CreateCharacterDiffs("someString", null, false)) as ArgumentNullException;

                Assert.NotNull(ex);
                Assert.Equal("newText", ex.ParamName);
            }
Beispiel #3
0
            public void Will_return_correct_one_item_list_when_no_insertions()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateCharacterDiffs("ab ce", "abce", false);

                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(0, res.DiffBlocks[0].InsertCountB);
            }
Beispiel #4
0
            public void Will_return_correct_one_item_list_for_strings_with_multiple_difference()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateCharacterDiffs("abcd", "abefgh", false);

                Assert.NotNull(res);
                Assert.Equal(1, res.DiffBlocks.Count);
                Assert.Equal(2, res.DiffBlocks[0].DeleteStartA);
                Assert.Equal(2, res.DiffBlocks[0].DeleteCountA);
                Assert.Equal(2, res.DiffBlocks[0].InsertStartB);
                Assert.Equal(4, res.DiffBlocks[0].InsertCountB);
            }
Beispiel #5
0
            public void Will_return_correct_diff_block_when_newText_is_empty_and_oldText_is_non_empty()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateCharacterDiffs("xy w", "", false);

                Assert.NotNull(res);
                Assert.Equal(1, res.DiffBlocks.Count);
                Assert.Equal(0, res.DiffBlocks[0].DeleteStartA);
                Assert.Equal(4, res.DiffBlocks[0].DeleteCountA);
                Assert.Equal(0, res.DiffBlocks[0].InsertStartB);
                Assert.Equal(0, res.DiffBlocks[0].InsertCountB);
            }
Beispiel #6
0
            public void Will_ignore_case_when_ignore_case_is_true()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateCharacterDiffs("zabcd", "XVABEFGH", false, true);

                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);
            }