Beispiel #1
0
        public void CountFrequencySorted()
        {
            const int repetitionCount = 3;
            var       input           = new[] { 1, 1, 1, 2, 2, 3, 3, 3 };
            const int expected        = 2;

            var actual = MissingNumber.CountFrequency(repetitionCount, input);

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void CountFrequencyUnsorted()
        {
            const int repetitionCount = 3;
            var       input           = new[] { 1, 2, 3, 1, 2, 3, 1, 3 };
            const int expected        = 2;

            var actual = MissingNumber.CountFrequency(repetitionCount, input);

            // Testing 'are not equal' because this algorithm only works when the numbers are sorted by value
            // It should fail on an unsorted array of numbers
            Assert.AreNotEqual(expected, actual);
        }