Exemplo 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
            });
        }
Exemplo 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");
        }
Exemplo 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");
        }
Exemplo 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");
        }
Exemplo 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");
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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");
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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
            });
        }
Exemplo n.º 14
0
 public ArithmeticService(IPrimeService primeService)
 {
     _primeService = primeService;
 }
Exemplo n.º 15
0
 public PrimeService(PrimeAlgorithmType_Values algoType)
 {
     AlgoType = algoType;
     _Inner   = GetPrimeService(algoType);
 }
Exemplo n.º 16
0
 public PrimeService(IPrimeService inner)
 {
     AlgoType = inner.AlgoType;
     _Inner   = inner;
 }
Exemplo n.º 17
0
 public PrimeServiceTest()
 {
     _primeService = new PrimeService();
 }
Exemplo n.º 18
0
 public PrimeServiceAdapter()
 {
     _primeService = new PrimeService();
 }
Exemplo n.º 19
0
 public PrimeService_IsPrimeShould()
 {
     primeService = new PrimeService();
 }
Exemplo n.º 20
0
 public PrimeServiceWithTimings(IPrimeService inner)
 {
     _Inner = inner;
 }
Exemplo n.º 21
0
 public PrimesController(IPrimeService primeService)
 {
     this.primeService = primeService;
 }
Exemplo n.º 22
0
 public PrimeFactorService(IPrimeService primeService)
 {
     _primeService = primeService;
 }
Exemplo n.º 23
0
 public Problem10(IPrimeService primeService)
 {
     _primeService = primeService;
 }
Exemplo n.º 24
0
        public PrimeController(IPrimeService primeService)
        {
            _primeService = primeService;

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