Example #1
0
        public void Given_array_When_sort_Then_return()
        {
            var array = new[] { 0, 1, 2, 0, 1, 2, 0, 1, 2 };

            SortColors.SortColorsFunc(array);

            Assert.AreEqual(new[] { 0, 0, 0, 1, 1, 1, 2, 2, 2 }, array);
        }
        public void TestZeroLen()
        {
            SortColors sc = new SortColors();

            int[] nums = new int[0];
            sc.SortCol(nums);

            Assert.AreEqual(0, nums.Length);
        }
Example #3
0
        public void TestSortColors()
        {
            var arr = new[] { 2, 1, 1, 0, 2, 2, 1, 0, 0, 2, 1, 2, 0, 1, 2, 0 };

            SortColors.Sort(arr);
            Assert.AreEqual(arr[4], 0);
            Assert.AreEqual(arr[5], 1);
            Assert.AreEqual(arr[10], 2);
        }
        public void Testnull()
        {
            SortColors sc = new SortColors();

            int[] nums = null;

            sc.SortCol(nums);

            Assert.AreEqual(null, nums);
        }
        public void TestFunction()
        {
            SortColors sc = new SortColors();

            int[] nums = new int[6] {
                2, 0, 2, 1, 1, 0
            };

            sc.SortCol(nums);

            int[] expected = new int[6] {
                0, 0, 1, 1, 2, 2
            };
            Assert.AreEqual(expected.Length, nums.Length);
            for (int i = 0; i < nums.Length; i++)
            {
                Assert.AreEqual(expected[i], nums[i]);
            }
        }
Example #6
0
 public void BeforeEach()
 {
     SortColors = new SortColors();
 }