Пример #1
0
            public void Will_return_list_of_length_zero_if_there_are_no_differences()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateLineDiffs("matt\ncatt\nhat\n", "matt\ncatt\nhat\n", false);

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

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

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

                var res = differ.CreateLineDiffs("matt\r\ncat\ntat\r\nhat\n", "matt\ncat\nhat\n", 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);
            }
Пример #4
0
            public void Will_return_correct_diff_block_when_newText_is_empty_and_oldText_is_non_empty()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateLineDiffs("matt\npat\nhat\n", "", 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);
            }
Пример #5
0
            public void Will_return_correct_one_item_list_for_strings_with_multiple_difference()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateLineDiffs("a\nb\nc\nd", "a\nb\ne\nf\ng\nh", 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);
            }
Пример #6
0
            public void Will_return_correct_one_item_list_for_strings_with_one_difference()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateLineDiffs("matt\ncat\nhat\n", "matt\npat\nhat\n", false);

                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(1, res.DiffBlocks[0].InsertStartB);
                Assert.Equal(1, res.DiffBlocks[0].InsertCountB);
            }
Пример #7
0
            public void Will_ignore_case_when_ignore_case_is_true()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateLineDiffs("z\t\na  \n b\nc\n\t\td", "X\nV\n A\nB\n E\nF\t\nG\nH\t\t", true, 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);
            }
Пример #8
0
            public void Will_return_correct_two_item_list_for_strings_with_multiple_difference_non_consecutively_and_ignoring_whitespace()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateLineDiffs("z\t\na  \n b\nc\n\t\td", "x\nv\n a\nb\n e\nf\t\ng\nh\t\t", 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);
            }
Пример #9
0
            public void Will_return_correct_two_item_list_for_strings_with_multiple_difference_non_conesecutivly()
            {
                var differ = new TestableDiffer();

                var res = differ.CreateLineDiffs("z\ra\nb\rc\nd", "x\nv\na\rb\ne\nf\ng\nh", false);

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