public async Task Is100000000_ThenNoValidationMessagesAreReturned()
        {
            //Arrange
            CalculateRequest request = new CalculateRequestBuilder()
                                       .WithValidDefaults()
                                       .WithLumpSum(100000000)
                                       .Build();

            var contents = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            //Act

            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);
        }
Esempio n. 2
0
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs10000_ThenYear100TotalInvestedIsCorrect()
        {
            //Arrange
            decimal expectedTotalInvestment = 1210000m;

            CalculateRequest request = new ForecastRequestViewModelBuilder()
                                       .WithValidDefaults()
                                       .WithInvestmentTerm(100)
                                       .Build();

            //Act
            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);

            Assert.AreEqual(expectedTotalInvestment, actual.TotalValue.ElementAt(100));
        }
        public async Task IsMinus1_ThenValidationMessagesAreReturned()
        {
            //Arrange
            int expectedValidationMessageCount = 1;
            CalculateRequest request           = new CalculateRequestBuilder()
                                                 .WithValidDefaults()
                                                 .WithLumpSum(-1)
                                                 .Build();

            var contents = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            //Act

            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsFalse(actual.Success);
            Assert.AreEqual(actual.ValidationMessages.Count(), expectedValidationMessageCount);
        }
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs10000_ThenYear100TotalInvestedIsCorrect()
        {
            //Arrange
            decimal expectedLowerValue = 2808782.36m;
            decimal expectedUpperValue = 5367931.32m;

            CalculateRequest request = new CalculateRequestBuilder()
                                       .WithValidDefaults()
                                       .WithInvestmentTerm(100)
                                       .Build();

            //Act
            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);
            Assert.AreEqual(expectedLowerValue, actual.NarrowLowerValue.ElementAt(100));
            Assert.AreEqual(expectedUpperValue, actual.NarrowUpperValue.ElementAt(100));
        }
Esempio n. 5
0
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs10000_ThenYear100TotalInvestedIsCorrect()
        {
            //Arrange
            decimal expectedLowerBound = 1210000m;
            decimal expectedUpperBound = 33346750.84m;

            CalculateRequest request = new CalculateRequestBuilder()
                                       .WithValidDefaults()
                                       .WithRiskLevel("medium")
                                       .WithInvestmentTerm(100)
                                       .Build();

            //Act
            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);
            Assert.AreEqual(expectedLowerBound, actual.WideLowerValue.ElementAt(100));
            Assert.AreEqual(expectedUpperBound, actual.WideUpperValue.ElementAt(100));
        }
Esempio n. 6
0
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs30000_ThenYear0TotalInvestedIsCorrect()
        {
            //Arrange
            decimal expectedTotalInvestment = 30000.00m;

            CalculateRequest request = new ForecastRequestViewModelBuilder()
                                       .WithValidDefaults()
                                       .WithLumpSum(expectedTotalInvestment)
                                       .Build();

            var contents = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            //Act

            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);
            Assert.AreEqual(expectedTotalInvestment, actual.TotalValue.ElementAt(0));
        }
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs10000_ThenYear100IsCorrect()
        {
            //Arrange
            decimal expectedLowerValue = 3853456.81m;
            decimal expectedUpperValue = 15626882.20m;

            CalculateRequest request = new CalculateRequestBuilder()
                                       .WithValidDefaults()
                                       .WithInvestmentTerm(100)
                                       .WithRiskLevel("high")
                                       .Build();

            //Act
            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);
            Assert.AreEqual(expectedLowerValue, actual.NarrowLowerValue.ElementAt(100));
            Assert.AreEqual(expectedUpperValue, actual.NarrowUpperValue.ElementAt(100));
        }
Esempio n. 8
0
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs10000_ThenYear0ValuesAreCorrect()
        {
            //Arrange
            decimal expectedLowerBound = 10000.00m;
            decimal expectedUpperBound = 10000.00m;

            CalculateRequest request = new CalculateRequestBuilder()
                                       .WithValidDefaults()
                                       .WithRiskLevel("medium")
                                       .Build();

            var contents = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            //Act

            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);
            Assert.AreEqual(expectedLowerBound, actual.WideLowerValue.ElementAt(0));
            Assert.AreEqual(expectedUpperBound, actual.WideUpperValue.ElementAt(0));
        }
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs10000_ThenYear1TotalInvestedIsCorrect()
        {
            //Arrange
            decimal expectedLowerValue = 22232.28m;
            decimal expectedUpperValue = 22386.89m;

            CalculateRequest request = new CalculateRequestBuilder()
                                       .WithValidDefaults()
                                       .WithInvestmentTerm(1)
                                       .Build();

            var contents = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            //Act

            Tests.Model.ForecastViewModel actual = await _apiHelper.Calculate(request);

            //Assert
            Assert.IsTrue(actual.Success);

            Assert.AreEqual(expectedLowerValue, actual.NarrowLowerValue.ElementAt(1));
            Assert.AreEqual(expectedUpperValue, actual.NarrowUpperValue.ElementAt(1));
        }