public void Random_Test() { Stopwatch sw = new Stopwatch(); const int tests = 1000; for (int i = 0; i < tests; ++i) { int[] test = new int[rnd.Next(0, 100)]; for (int j = 0; j < test.Length; ++j) { test[j] = rnd.Next(-15, 16); } int[] clone = (int[])test.Clone(); sw.Start(); int actual = FindCountOfMostFrequentItemInAnArray.MostFrequentItemCount(test); sw.Stop(); Assert.AreEqual(test, clone, "User mutated the input array!"); int expected = solution(test); Assert.AreEqual(expected, actual, "input: {" + String.Join(", ", test) + "}"); } Console.WriteLine("Random tests passed!\nTotal user code execution time was {0}ms over {1} assertions", sw.Elapsed.TotalMilliseconds, tests); }
public void Edge_Test(int[] test, int expected) { Assert.AreEqual(expected, FindCountOfMostFrequentItemInAnArray.MostFrequentItemCount(test)); }