public void Should_Return_All_Prime_Numers_Divisors_Of_40(int number)
        {
            var resultQuery = CalculateDivisorQueries.GetDividersByNumber(number);
            var equals      = Enumerable.SequenceEqual(first: resultQuery.Primes, second: _primesDividersOf40);

            Assert.IsTrue(equals);
        }
Ejemplo n.º 2
0
 private static CalculateDivisorResult Calculate(int number)
 {
     try
     {
         return(CalculateDivisorQueries.GetDividersByNumber(number));
     }
     catch (Exception ex)
     {
         return(new CalculateDivisorResult(false, ex.Message));
     }
 }
Ejemplo n.º 3
0
 public async Task <IActionResult> CalculateDivisorByNumber(int number)
 {
     try
     {
         var queryResult = CalculateDivisorQueries.GetDividersByNumber(number);
         return(await Task.FromResult(Ok(queryResult)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public void Should_Return_Error_When_Number_Lower_Or_Equal_Than_Zero(int number)
        {
            var resultQuery = CalculateDivisorQueries.GetDividersByNumber(number);

            Assert.IsFalse(resultQuery.Success);
        }
        public void Should_Return_Three_Primes_Numbers(int number)
        {
            var resultQuery = CalculateDivisorQueries.GetDividersByNumber(number);

            Assert.AreEqual(expected: 3, actual: resultQuery.Primes.Count());
        }