예제 #1
0
        public void Given_list_1_2_3_4_and_empty_list_should_get_1_2_3_4()
        {
            var list1 = new[] {1, 2, 3, 4};
            var list2 = new int[] {};

            var sorter = new MergeSorter<int>();
            var result = sorter.Merge(list1, list2, (a, b) => a.CompareTo(b)).ToList();
            result.ShouldContainAllInOrder(new[] {1, 2, 3, 4});
        }
예제 #2
0
        public void Given_lists_5_6_7_and_1_2_3_4_should_get_1_2_3_4_5_6_7()
        {
            var list1 = new[] {5, 6, 7};
            var list2 = new[] {1, 2, 3, 4};

            var sorter = new MergeSorter<int>();
            var result = sorter.Merge(list1, list2, (a, b) => a.CompareTo(b)).ToList();
            result.ShouldContainAllInOrder(new[] {1, 2, 3, 4, 5, 6, 7});
        }
예제 #3
0
        public void Given_empty_list_and_list_5_6_7_should_get_5_6_7()
        {
            var list1 = new int[] {};
            var list2 = new[] {5, 6, 7};

            var sorter = new MergeSorter<int>();
            var result = sorter.Merge(list1, list2, (a, b) => a.CompareTo(b)).ToList();
            result.ShouldContainAllInOrder(new[] {5, 6, 7});
        }
예제 #4
0
        public void TestingMerge6()
        {
            List<int> list1 = new List<int>() { 2 };
            List<int> list2 = new List<int>() { 1, 4 };
            MergeSorter<int> ms = new MergeSorter<int>();
            var result = ms.Merge(list1, list2);
            IList<int> sortedList = new List<int>() { 1, 2, 4 };

            Assert.AreEqual(string.Join(",", sortedList), string.Join(",", result));
        }
예제 #5
0
        public void TestingMerge3()
        {
            List<int> list1 = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
            List<int> list2 = new List<int>() { 9 };
            MergeSorter<int> ms = new MergeSorter<int>();
            var result = ms.Merge(list1, list2);
            IList<int> sortedList = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

            Assert.AreEqual(string.Join(",", sortedList), string.Join(",", result));
        }
예제 #6
0
 public void ShouldMerge2ItemsAscendings()
 {
     Assert.That(MergeSorter.Merge(new[] { 2 }, new[] { 1 }), Is.EqualTo(new[] { 1, 2 }));
 }
예제 #7
0
 public void ShouldMergeArraysWithEqualEntries()
 {
     Assert.That(MergeSorter.Merge(new[] { 1, 3, 5 }, new[] { 1, 2, 3 }), Is.EqualTo(new[] { 1, 1, 2, 3, 3, 5 }));
 }
예제 #8
0
 public void ShouldMergeDifferentSizedArrays()
 {
     Assert.That(MergeSorter.Merge(new[] { 2 }, new[] { 1, 3 }), Is.EqualTo(new[] { 1, 2, 3 }));
 }
예제 #9
0
        public void Given_two_empty_lists_should_get_an_empty_list()
        {
            var list1 = new int[] {};
            var list2 = new int[] {};

            var sorter = new MergeSorter<int>();
            var result = sorter.Merge(list1, list2, (a, b) => a.CompareTo(b)).ToList();
            result.ShouldBeEmpty();
        }