Exemple #1
0
        public void RandomTest()
        {
            for (int i = 0; i < 10; ++i)
            {
                List <int> testList = new List <int>();
                int        offset   = rnd.Next(0, 20) - 10;
                for (int j = 0; j < 20; ++j)
                {
                    testList.Add(offset + (rnd.Next(0, 9)));
                }
                testList.Sort((a, b) => a - b);
                testList = testList.Distinct().ToList();
                Console.WriteLine(string.Join(", ", testList.ToArray()));
                object first    = Solutions.FirstNonConsecutive.Solution(testList.ToArray());
                object expected = FirstNonConsecutive.Solution(testList.ToArray());

                Assert.AreEqual(expected, first);
            }
        }
Exemple #2
0
 public void SequentialTest()
 {
     Assert.AreEqual(null, FirstNonConsecutive.Solution(new int[] { 1, 2, 3, 4 }));
 }
Exemple #3
0
 public void NegativeTest()
 {
     Assert.AreEqual(-1, FirstNonConsecutive.Solution(new int[] { -3, -1, 0, 1, 2 }));
 }
Exemple #4
0
 public void ZeroTest()
 {
     Assert.AreEqual(0, FirstNonConsecutive.Solution(new int[] { -3, -2, 0, 1, 2 }));
 }
Exemple #5
0
 public void SimpleTest()
 {
     Assert.AreEqual(6, FirstNonConsecutive.Solution(new int[] { 1, 2, 3, 4, 6, 7, 8 }));
 }
Exemple #6
0
 public void SingleElemntArrayTest()
 {
     Assert.IsNull(FirstNonConsecutive.Solution(new int[] { 0 }));
 }
Exemple #7
0
 public void EmptyArrayTest()
 {
     Assert.IsNull(FirstNonConsecutive.Solution(new int[0]));
 }