Esempio n. 1
0
        public void GetPrimeNumbers_ShouldReturnAllPrimesForGivenStartAndEnd()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);

            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(2, 4, new List <int> {
                2, 3
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(2, 5, new List <int> {
                2, 3, 5
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(2, 6, new List <int> {
                2, 3, 5
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(4, 7, new List <int> {
                5, 7
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(2, 10, new List <int> {
                2, 3, 5, 7
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(1, 11, new List <int> {
                2, 3, 5, 7, 11
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(8, 11, new List <int> {
                11
            });
        }
Esempio n. 2
0
        public void IsPrime_ShouldReturnTrue_IfNumberIsThree()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.SieveOfEratosthenes);

            bool actual = _Sut.IsPrime(3);

            Assert.IsTrue(actual, "3 is a prime number");
        }
Esempio n. 3
0
        public void IsPrime_ShouldReturnFalse_IfNumberIsFour()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);

            bool actual = _Sut.IsPrime(4);

            Assert.IsFalse(actual, "4 is not a prime number");
        }
Esempio n. 4
0
        public void IsPrime_ShouldReturnFalse_IfNumberIsOne()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.SieveOfEratosthenes);

            bool actual = _Sut.IsPrime(1);

            Assert.IsFalse(actual, "1 is not a prime number");
        }
Esempio n. 5
0
        public void IsPrime_ShouldReturnTrue_IfNumberIsPrime(int number)
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);

            bool actual = _Sut.IsPrime(number);

            Assert.IsTrue(actual, $"{number} is a prime number");
        }
Esempio n. 6
0
        public void InstantiateWithPrimeHelper_ShouldReturnAlgoTypeCorrectly()
        {
            MockPrimeService innerPrimeHelper = new MockPrimeService();

            _Sut = new PrimeService(innerPrimeHelper);

            PrimeAlgorithmType_Values algoType = _Sut.AlgoType;

            Assert.AreEqual(PrimeAlgorithmType_Values._NotDefined, algoType);
        }
Esempio n. 7
0
        public void GetPrimeNumbers_ShouldReturnEmptyForInputOne()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);
            int        input          = 1;
            List <int> expectedPrimes = new List <int> {
            };

            List <int> primes = _Sut.GetPrimeNumbers(input);

            CollectionAssert.AreEqual(expectedPrimes, primes);
        }
Esempio n. 8
0
        public void IsPrime_ShouldReturnFalse_IfNumberLessThanOrEqToZero()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);

            bool actual = _Sut.IsPrime(0);

            Assert.IsFalse(actual, "0(zero) is not a prime number");

            actual = _Sut.IsPrime(-1);
            Assert.IsFalse(actual, "-1 is not a prime number");
        }
Esempio n. 9
0
        public void GetPrimeNumbers_ShouldThrowArgumentExceptionIfStartGreaterThanEnd()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);
            int        start          = 2;
            int        end            = 1;
            List <int> expectedPrimes = new List <int> {
            };

            List <int> primes = _Sut.GetPrimeNumbers(start, end);

            CollectionAssert.AreEqual(expectedPrimes, primes);
        }
Esempio n. 10
0
        public void GetPrimeNumbers_ShouldReturnTwoAndThreeForInputThree()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.SieveOfEratosthenes);
            int        input          = 3;
            List <int> expectedPrimes = new List <int> {
                2, 3
            };

            List <int> primes = _Sut.GetPrimeNumbers(input);

            CollectionAssert.AreEqual(expectedPrimes, primes);
        }
Esempio n. 11
0
        public void GetPrimeNumbers_ShouldReturnEmptyForInputOneAndOne()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.SieveOfEratosthenes);
            int        start          = 1;
            int        end            = 1;
            List <int> expectedPrimes = new List <int> {
            };

            List <int> primes = _Sut.GetPrimeNumbers(start, end);

            CollectionAssert.AreEqual(expectedPrimes, primes);
        }
Esempio n. 12
0
        public void GetPrimeNumbers_ShouldReturnThreeForInputThreeAndThree()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);
            int        start          = 3;
            int        end            = 3;
            List <int> expectedPrimes = new List <int> {
                3
            };

            List <int> primes = _Sut.GetPrimeNumbers(start, end);

            CollectionAssert.AreEqual(expectedPrimes, primes);
        }
Esempio n. 13
0
        public void GetPrimeNumbers_ShouldReturnAllPrimesForGivenInput()
        {
            _Sut = new PrimeService(PrimeAlgorithmType_Values.BruteForce);

            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(4, new List <int> {
                2, 3
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(5, new List <int> {
                2, 3, 5
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(6, new List <int> {
                2, 3, 5
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(7, new List <int> {
                2, 3, 5, 7
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(10, new List <int> {
                2, 3, 5, 7
            });
            Assert_GetPrimeNumbers_ReturnsExpectedPrimes(11, new List <int> {
                2, 3, 5, 7, 11
            });
        }
Esempio n. 14
0
 public ArithmeticService(IPrimeService primeService)
 {
     _primeService = primeService;
 }
Esempio n. 15
0
 public PrimeService(PrimeAlgorithmType_Values algoType)
 {
     AlgoType = algoType;
     _Inner   = GetPrimeService(algoType);
 }
Esempio n. 16
0
 public PrimeService(IPrimeService inner)
 {
     AlgoType = inner.AlgoType;
     _Inner   = inner;
 }
Esempio n. 17
0
 public PrimeServiceTest()
 {
     _primeService = new PrimeService();
 }
Esempio n. 18
0
 public PrimeServiceAdapter()
 {
     _primeService = new PrimeService();
 }
Esempio n. 19
0
 public PrimeService_IsPrimeShould()
 {
     primeService = new PrimeService();
 }
Esempio n. 20
0
 public PrimeServiceWithTimings(IPrimeService inner)
 {
     _Inner = inner;
 }
Esempio n. 21
0
 public PrimesController(IPrimeService primeService)
 {
     this.primeService = primeService;
 }
Esempio n. 22
0
 public PrimeFactorService(IPrimeService primeService)
 {
     _primeService = primeService;
 }
Esempio n. 23
0
 public Problem10(IPrimeService primeService)
 {
     _primeService = primeService;
 }
Esempio n. 24
0
        public PrimeController(IPrimeService primeService)
        {
            _primeService = primeService;

            _badResult = Json(new { result = false });
        }
Esempio n. 25
0
 public PrimeViewModel(IPrimeService primeService)
 {
     _primeService = primeService;
 }
Esempio n. 26
0
 public PrimeController(IPrimeService primeService)
 {
     _primeService = primeService;
 }