public void post_withValidAge_ReturnsPremium() { //Arrange _ageCalculator = new Mock <IAgeCalculator>(); _ageCalculator.Setup(y => y.CalcAge(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(36); _premiumController = new PremiumController(_premiumCalculator.Object, _ageCalculator.Object, _logger.Object, _appConfig); //Act _customerModel = TestHelper.GetCustomer("dheeraj", "male", new DateTime(1981, 10, 16)); var resultObject = _premiumController.Post(_customerModel); var okResult = resultObject as OkObjectResult; //Assert Assert.IsNotNull(okResult); Assert.IsTrue(okResult.Value.ToString().ToLower() == "dheeraj, your premium amount is 4320."); }
public void post_withInValidAge_ReturnsWarningMessage() { //Arrange _ageCalculator = new Mock <IAgeCalculator>(); _ageCalculator.Setup(y => y.CalcAge(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(10); _premiumController = new PremiumController(_premiumCalculator.Object, _ageCalculator.Object, _logger.Object, _appConfig); //Act _customerModel = TestHelper.GetCustomer("dheeraj", "male", new DateTime(2008, 10, 16)); var resultObject = _premiumController.Post(_customerModel); var okResult = resultObject as OkObjectResult; //Assert Assert.IsNotNull(okResult); Assert.IsTrue(okResult.Value.ToString().ToLower() == "sorry dheeraj, we offer our services to person aged b/w 18 and 65."); }