public void MergeTest()
        {
            var nums1 = new int[] { 1, 4, 6, 7, 9, 0, 0, 0, 0 };
            var nums2 = new int[] { 2, 3, 8, 10 };

            MergeSortedArrays.Merge(nums1, nums1.Length - nums2.Length, nums2, nums2.Length).Should().BeEquivalentTo(new int[] { 1, 2, 3, 4, 6, 7, 8, 9, 10 });
        }
Exemple #2
0
    public static void Main()
    {
        Console.WriteLine("Hello");

        int [] array1     = new int [] { 2, 4, 6, 8, 50 };
        int [] array2     = new int [] { 3, 5, 7, 9, 13, 20, 50 };
        int [] mergeArray = MergeSortedArrays.Merge(array1, array2);

        Console.WriteLine(string.Join(",", mergeArray));
    }
        private static void MergeArrays()
        {
            MergeSortedArrays m = new MergeSortedArrays();

            int[] firstArr  = { 0, 3, 4, 31 };
            int[] secondArr = { 4, 6, 30 };
            int[] mergedArr = m.Merge(firstArr, secondArr);
            Print(mergedArr);
            Console.ReadKey();
        }
        public void Merge_Test()
        {
            //arrange
            int[]             inputArray1 = { };
            int[]             inputArray2 = { 1, 2, 3, 4, 5, 7 };
            int[]             expected    = { 1, 2, 3, 4, 5, 7 };
            MergeSortedArrays merger      = new MergeSortedArrays(inputArray1, inputArray2);

            //act
            merger.Merge();

            //assert
            CollectionAssert.AreEqual(expected, merger.MergedArray);
        }