Beispiel #1
0
        public async Task InterestCompoundCalculatorUnitTest_BiggerThanInitialValueAsync()
        {
            var initialValue = 100;
            var months       = 5;

            var compoundCalculatorService = new CompoundCalculatorService(interestRateServiceMock.Object);
            var result = await compoundCalculatorService.CalculateCompoundInterestAsync(initialValue, months);

            Assert.True(result > initialValue);
        }
Beispiel #2
0
        public IActionResult Calculate([FromForm] CalculatorData myData)
        {
            var svc    = new CompoundCalculatorService();
            var result = svc.CalculateCompoundInterest(myData);

            if (result != -1)
            {
                myData.CalcResults = result;
            }
            return(View(myData));
        }
        public async Task InterestCompoundCalculateIntegrationTest_IncorrectURLAsync()
        {
            var initialValue = 100;
            var months = 5;

            var configurationMock = new Mock<IConfiguration>();
            configurationMock.SetupGet(c => c["InterestRateHost"]).Returns("/taxaDeJuros");

            var interestRateService = new InterestRateService(httpClientFactory, configurationMock.Object);
            var compoundCalculatorService = new CompoundCalculatorService(interestRateService);

            await Assert.ThrowsAsync<HttpRequestException>(async () => await compoundCalculatorService.CalculateCompoundInterestAsync(initialValue, months));
        }
        public async Task InterestCompoundCalculateIntegrationTest_CorrectURLAsync()
        {
            var initialValue = 100;
            var months = 5;

            var configurationMock = new Mock<IConfiguration>();
            configurationMock.SetupGet(c => c["InterestRateHost"]).Returns("/taxaJuros");

            var interestRateService = new InterestRateService(httpClientFactory, configurationMock.Object);
            var compoundCalculatorService = new CompoundCalculatorService(interestRateService);
            var compoundCalculateValue = await compoundCalculatorService.CalculateCompoundInterestAsync(initialValue, months);

            Assert.True(compoundCalculateValue > initialValue);
        }
Beispiel #5
0
        public async Task InterestCompoundCalculatorUnitTest_ArgumentValidationAsync(decimal initialValue, int months)
        {
            var compoundCalculatorService = new CompoundCalculatorService(interestRateServiceMock.Object);

            await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await compoundCalculatorService.CalculateCompoundInterestAsync(initialValue, months));
        }