Exemplo n.º 1
0
        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));
        }
        public async Task Is10000001_ThenValidationMessagesAreReturned()
        {
            //Arrange
            int expectedValidationMessageCount = 1;
            CalculateRequest request           = new CalculateRequestBuilder()
                                                 .WithValidDefaults()
                                                 .WithMonthlyInvestment(10000001)
                                                 .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 expectedTotalInvestment = 1210000m;

            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(expectedTotalInvestment, actual.TotalValue.ElementAt(100));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        public async Task AndMonthlyInvestmentIs1000_AndLumpSumIs30000_ThenYear0TotalInvestedIsCorrect()
        {
            //Arrange
            decimal expectedTotalInvestment = 30000.00m;

            CalculateRequest request = new CalculateRequestBuilder()
                                       .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));
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
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));
        }