public async Task Administrator_Calculates_Deductible_With_Negative_Tax_Rate() { //Arrange var calculateService = new CalculateService(); var taxRateService = new TaxRateService(); var controller = new CalculatorController(calculateService, taxRateService); //Act ViewResult result = await controller.Index(25000, -20, null) as ViewResult; //Assert Assert.IsNotNull(result); Assert.IsNotNull(result.Model); Assert.IsInstanceOfType(result.Model, typeof(CalculatedVM)); Assert.AreEqual(0, ((CalculatedVM)result.Model).DonatedAmount); Assert.AreEqual(0, ((CalculatedVM)result.Model).TaxRate); Assert.AreEqual("0", ((CalculatedVM)result.Model).Supplement); Assert.AreEqual(0, ((CalculatedVM)result.Model).DeductibleAmount); Assert.AreEqual("Enter a positive tax rate!", ((CalculatedVM)result.Model).ErrorMessage); Assert.AreEqual(0, taxRateService.GetTaxRate()); }
public async Task Administrator_Changes_Tax_Rate() { //Arrange var calculateService = new CalculateService(); var taxRateService = new TaxRateService(); var controller = new CalculatorController(calculateService, taxRateService); //Act ViewResult result = await controller.Index(25000, 25, null) as ViewResult; //Assert Assert.IsNotNull(result); Assert.IsNotNull(result.Model); Assert.IsInstanceOfType(result.Model, typeof(CalculatedVM)); Assert.AreEqual(25000, ((CalculatedVM)result.Model).DonatedAmount); Assert.AreEqual(25, ((CalculatedVM)result.Model).TaxRate); Assert.AreEqual("0", ((CalculatedVM)result.Model).Supplement); Assert.AreEqual(8333.333984375, ((CalculatedVM)result.Model).DeductibleAmount); Assert.AreEqual(null, ((CalculatedVM)result.Model).ErrorMessage); Assert.AreEqual(25, taxRateService.GetTaxRate()); }