Пример #1
0
            public void Will_return_correct_edit_length_random_strings(int[] a, int[] b, int actualEditLength)
            {
                var differ = new TestableDiffer();

                var res = differ.TestCalculateEditLength(a, 0, a.Length, b, 0, b.Length);

                Assert.Equal(actualEditLength, res.EditLength);
            }
Пример #2
0
            public void Will_return_length_0_for_arrays()
            {
                var differ = new TestableDiffer();

                var res = differ.TestCalculateEditLength(new int[0], 0, 0, new int[0], 0, 0);

                Assert.Equal(0, res.EditLength);
            }
Пример #3
0
            public void Will_return_correct_length_when_start_and_ends_are_changed()
            {
                var differ = new TestableDiffer();

                int[] b = { 1, 2, 3, 0, 5, 6, 7, 8 };
                int[] a = { 4, 2, 3, 4, 5, 6, 7, 9 };

                var res = differ.TestCalculateEditLength(a, 1, a.Length - 1, b, 1, b.Length - 1);

                Assert.Equal(2, res.EditLength);
            }
Пример #4
0
            public void Will_return_length_of_b_if_a_is_empty()
            {
                var differ = new TestableDiffer();

                int[] b = { 1, 2, 3, 4, 5, 6, 7, 8 };
                int[] a = { };

                var res = differ.TestCalculateEditLength(a, 0, a.Length, b, 0, b.Length);

                Assert.Equal(b.Length, res.EditLength);
            }
Пример #5
0
            public void Will_throw_if_arrays_are_null()
            {
                var differ = new TestableDiffer();

                int[] a = null;
                int[] b = null;

                var ex = Record.Exception(() => differ.TestCalculateEditLength(a, 0, 0, b, 0, 0)) as ArgumentNullException;

                Assert.NotNull(ex);
            }
Пример #6
0
            public void Will_return_snake_of_zero_length_for_unique_arrays()
            {
                var differ = new TestableDiffer();

                int[] a = { 1, 2, 3, 4, 5, 6, 7, 8 };
                int[] b = { 11, 12, 23, 54, 56 };

                var res = differ.TestCalculateEditLength(a, 0, a.Length, b, 0, b.Length);

                Assert.Equal(res.StartX, res.EndX);
                Assert.Equal(res.StartY, res.EndY);
                Assert.Equal(a.Length + b.Length, res.EditLength);
            }