public void TestModAlgorithm()
        {
            var multiplesOfSeven = new HashSet <uint> {
                0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98
            };

            for (uint i = 0; i <= 100; ++i)
            {
                Assert.AreEqual(multiplesOfSeven.Contains(i), _modChecker.IsDivisibleBySeven(i));
            }
        }
 private void TestDivisibilityChecker(ICheckDivisibilityBySeven divisibilityChecker)
 {
     for (uint i = 0; i <= MaxTestValue; ++i)
     {
         Assert.AreEqual(_modChecker.IsDivisibleBySeven(i), divisibilityChecker.IsDivisibleBySeven(i));
     }
 }
 private long TimeTakenInMilliseconds(ICheckDivisibilityBySeven checker)
 {
     Stopwatch stopWatch = new Stopwatch();
     stopWatch.Start();
     for (uint i = 0; i <= TestValueCount; ++i)
     {
         checker.IsDivisibleBySeven(i);
     }
     stopWatch.Stop();
     return stopWatch.ElapsedMilliseconds;
 }
        private void PerformanceTestBitShiftAlgorithm(ICheckDivisibilityBySeven standardChecker, double acceptableFactor)
        {
            // Code to prime the jitter.
            _bitShiftChecker.IsDivisibleBySeven(1337);
            standardChecker.IsDivisibleBySeven(1337);

            long bitShiftMilliseconds = TimeTakenInMilliseconds(_bitShiftChecker);
            long typicalMethodMilliseconds = TimeTakenInMilliseconds(standardChecker);

            var speedUpFactor = typicalMethodMilliseconds/(double) bitShiftMilliseconds;
            Assert.GreaterOrEqual(speedUpFactor, acceptableFactor);
        }
        private long TimeTakenInMilliseconds(ICheckDivisibilityBySeven checker)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            for (uint i = 0; i <= TestValueCount; ++i)
            {
                checker.IsDivisibleBySeven(i);
            }
            stopWatch.Stop();
            return(stopWatch.ElapsedMilliseconds);
        }
        private void PerformanceTestBitShiftAlgorithm(ICheckDivisibilityBySeven standardChecker, double acceptableFactor)
        {
            // Code to prime the jitter.
            _bitShiftChecker.IsDivisibleBySeven(1337);
            standardChecker.IsDivisibleBySeven(1337);

            long bitShiftMilliseconds      = TimeTakenInMilliseconds(_bitShiftChecker);
            long typicalMethodMilliseconds = TimeTakenInMilliseconds(standardChecker);

            var speedUpFactor = typicalMethodMilliseconds / (double)bitShiftMilliseconds;

            Assert.GreaterOrEqual(speedUpFactor, acceptableFactor);
        }
 private void TestDivisibilityChecker(ICheckDivisibilityBySeven divisibilityChecker)
 {
     for (uint i = 0; i <= MaxTestValue; ++i)
         Assert.AreEqual(_modChecker.IsDivisibleBySeven(i), divisibilityChecker.IsDivisibleBySeven(i));
 }