public void Test_GetPayslip_3() { var payslipController = new PaySlipController(new PaySlipService()); payslipController.Request = new HttpRequestMessage(); payslipController.Configuration = new HttpConfiguration(); var employee = new PaySlipInputModel() { FirstName = "Durgesh", LastName = "Pandey", AnualSalary = 10000, PaymentStartDate = (new DateTime(2018, 06, 30)).ToShortDateString(), SuperRate = 0 }; PaySlipModel paySlip; var response = (HttpResponseMessage)payslipController.GetPaySlip(employee); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); Assert.IsTrue(response.TryGetContentValue <PaySlipModel>(out paySlip)); Assert.IsNotNull(paySlip); Assert.AreEqual(833, paySlip.GrossIncome); Assert.AreEqual(0, paySlip.IncomeTax); Assert.AreEqual(833, paySlip.NetIncome); Assert.AreEqual(0, paySlip.SuperAmount); }
public async Task When_FirstName_is_invalid_then_bad_request_is_expected() { _controller = new PaySlipController(_paySlipCalculator.Object); _controller.ModelState.AddModelError("FirstName", "Invalid"); var result = await _controller.GetPaySlip(_request); //Assert.AreEqual(null, result); }
public void NegativeTest_GetPayslip1() { var payslipController = new PaySlipController(new PaySlipService()); payslipController.Request = new HttpRequestMessage(); payslipController.Configuration = new HttpConfiguration(); var response = (payslipController.GetPaySlip(null)); // Assert Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest); }
public void SetUp() { _paySlipCalculator = new Mock <IPaySlipCalculator>(); _paySlipCalculator.Setup(x => x.GetPaySlip(It.IsAny <PaySlipRequest>())) .Returns(Task.FromResult(new PaySlipResponse())); _controller = new PaySlipController(_paySlipCalculator.Object); _request = new PaySlipRequest { AnnualSalary = 10000, FirstName = "Shishira", LastName = "Mallasandra", SuperInterestRate = 9, PaymentStartDate = DateTime.Now }; }
public void NegativeTest_GetPayslip2() { var payslipController = new PaySlipController(new PaySlipService()); payslipController.Request = new HttpRequestMessage(); payslipController.Configuration = new HttpConfiguration(); var employee = new PaySlipInputModel() { FirstName = "Durgesh", LastName = "Pandey", AnualSalary = -200, PaymentStartDate = (new DateTime(2018, 06, 30)).ToShortDateString(), SuperRate = -3 }; var response = (payslipController.GetPaySlip(employee)); // Assert Assert.AreEqual(response.StatusCode, HttpStatusCode.InternalServerError); }