Beispiel #1
0
        static void Main(string[] args)
        {
            IMathOperationService mathService = new MathOperationService(20, 10);

            Console.WriteLine($"Add - {mathService.Add()}");
            Console.WriteLine($"Sub - {mathService.Sub()}");
            Console.WriteLine($"Div - {mathService.Div()}");
            Console.WriteLine($"Mul - {mathService.Mul()}");
            Console.ReadLine();
        }
Beispiel #2
0
        public void IsPrime_GivenNonPrimesValue_ReturnFalse()
        {
            //Arrange
            int  inputValue     = 4;
            bool expectedResult = false;
            //Act
            var result = MathOperationService.IsPrime(inputValue);

            //Assert
            Assert.Equal(expectedResult, result);
        }
Beispiel #3
0
        public void Task_Divide_TwoNumber()
        {
            // Arrange
            var num1          = 2.9;
            var num2          = 3.1;
            var expectedValue = 0.94; //Rounded value

            // Act
            var div = MathOperationService.Divide(num1, num2);

            //Assert
            Assert.Equal(expectedValue, div, 2);
        }
Beispiel #4
0
        public void Task_Multiply_TwoNumber()
        {
            // Arrange
            var num1          = 2.9;
            var num2          = 3.1;
            var expectedValue = 8.99;

            // Act
            var mult = MathOperationService.Multiply(num1, num2);

            //Assert
            Assert.Equal(expectedValue, mult, 2);
        }
Beispiel #5
0
        public void Task_Subtract_TwoNumber()
        {
            // Arrange
            var num1          = 2.9;
            var num2          = 3.1;
            var expectedValue = -0.2;

            // Act
            var sub = MathOperationService.Subtract(num1, num2);

            //Assert
            Assert.Equal(expectedValue, sub, 1);
        }
Beispiel #6
0
        public void Task_Add_TwoNumber()
        {
            // Arrange
            var num1          = 2.9;
            var num2          = 3.1;
            var expectedValue = 6;

            // Act
            var sum = MathOperationService.Add(num1, num2);

            //Assert
            Assert.Equal(expectedValue, sum, 1);
        }
Beispiel #7
0
        public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req, ILogger log)
        {
            IMathOperationService    mathService = new MathOperationService(20, 5);
            Dictionary <string, int> obj         = new Dictionary <string, int>();

            log.LogInformation($"Add - {mathService.Add()}");
            obj.Add("Add", mathService.Add());

            log.LogInformation($"Sub - {mathService.Sub()}");
            obj.Add("Sub", mathService.Sub());

            log.LogInformation($"Mul - {mathService.Mul()}");
            obj.Add("Mul", mathService.Mul());

            log.LogInformation($"Div - {mathService.Div()}");
            obj.Add("Div", mathService.Div());

            return((ActionResult) new OkObjectResult(obj));
        }
Beispiel #8
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestMessage req, TraceWriter log)
        {
            IMathOperationService    mathService = new MathOperationService(20, 5);
            Dictionary <string, int> obj         = new Dictionary <string, int>();

            log.Info($"Add - {mathService.Add()}");
            obj.Add("Add", mathService.Add());

            log.Info($"Sub - {mathService.Sub()}");
            obj.Add("Sub", mathService.Sub());

            log.Info($"Mul - {mathService.Mul()}");
            obj.Add("Mul", mathService.Mul());

            log.Info($"Div - {mathService.Div()}");
            obj.Add("Div", mathService.Div());

            return(req.CreateResponse(HttpStatusCode.OK, obj));
        }