Beispiel #1
0
        public void Test_GetPayslip_3()
        {
            var payslipController = new PayslipController();

            payslipController.Request       = new HttpRequestMessage();
            payslipController.Configuration = new HttpConfiguration();
            var employee = new Employee()
            {
                FirstName    = "Uvika",
                LastName     = "Khatri",
                AnnualSalary = 10000,
                StartDate    = new DateTime(2018, 06, 30),
                SuperRate    = 0
            };

            Payslip paySlip;
            var     response = payslipController.CreatePaySlip(employee);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            Assert.IsTrue(response.TryGetContentValue <Payslip>(out paySlip));
            Assert.IsNotNull(paySlip);
            Assert.AreEqual(833, paySlip.GrossIncome);
            Assert.AreEqual(0, paySlip.IncomeTax);
            Assert.AreEqual(833, paySlip.NetIncome);
            Assert.AreEqual(0, paySlip.SuperAnnuation);
            Assert.AreEqual("01 Jun 2018-30 Jun 2018", paySlip.PayPeriod);
        }
Beispiel #2
0
        public void Test_GetPayslip_1()
        {
            var payslipController = new PayslipController();

            var employee = new Employee()
            {
                FirstName    = "Uvika",
                LastName     = "Khatri",
                AnnualSalary = 60050,
                StartDate    = new DateTime(2018, 03, 01),
                SuperRate    = 9
            };



            payslipController.Request       = new HttpRequestMessage();
            payslipController.Configuration = new HttpConfiguration();

            Payslip paySlip;
            var     response = payslipController.CreatePaySlip(employee);

            Assert.IsTrue(response.TryGetContentValue <Payslip>(out paySlip));
            Assert.IsNotNull(paySlip);
            Assert.AreEqual(5004, paySlip.GrossIncome);
            Assert.AreEqual(922, paySlip.IncomeTax);
            Assert.AreEqual(4082, paySlip.NetIncome);
            Assert.AreEqual(450, paySlip.SuperAnnuation);
            Assert.AreEqual("01 Mar 2018-31 Mar 2018", paySlip.PayPeriod);
        }
Beispiel #3
0
        public void NegativeTest_GetPayslip1()
        {
            var payslipController = new PayslipController();
            var result            = (payslipController.CreatePaySlip(null));

            // Assert
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Beispiel #4
0
        public void NegativeTest_GetPayslip1()
        {
            var payslipController = new PayslipController();

            payslipController.Request       = new HttpRequestMessage();
            payslipController.Configuration = new HttpConfiguration();
            var response = (payslipController.CreatePaySlip(null));

            // Assert
            Assert.AreEqual(response.StatusCode, HttpStatusCode.NotFound);
        }
Beispiel #5
0
        public void NegativeTest_GetPayslip2()
        {
            var payslipController = new PayslipController();

            var employee = new Employee()
            {
                FirstName    = "Uvika",
                LastName     = "Khatri",
                AnnualSalary = -200,
                StartDate    = new DateTime(2018, 06, 30),
                SuperRate    = -3
            };

            var result = (payslipController.CreatePaySlip(employee));

            // Assert
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Beispiel #6
0
        public void NegativeTest_GetPayslip2()
        {
            var payslipController = new PayslipController();

            payslipController.Request       = new HttpRequestMessage();
            payslipController.Configuration = new HttpConfiguration();
            var employee = new Employee()
            {
                FirstName    = "Uvika",
                LastName     = "Khatri",
                AnnualSalary = -200,
                StartDate    = new DateTime(2018, 06, 30),
                SuperRate    = -3
            };

            var response = (payslipController.CreatePaySlip(employee));

            // Assert
            Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest);
        }
Beispiel #7
0
        public void Test_GetPayslip_4()
        {
            var payslipController = new PayslipController();

            var employee = new Employee()
            {
                FirstName    = "Uvika",
                LastName     = "Khatri",
                AnnualSalary = 20000,
                StartDate    = new DateTime(2018, 06, 30),
                SuperRate    = 3
            };

            var paySlip = (payslipController.CreatePaySlip(employee) as OkNegotiatedContentResult <Payslip>).Content;

            Assert.IsNotNull(paySlip);
            Assert.AreEqual(1667, paySlip.GrossIncome);
            Assert.AreEqual(28, paySlip.IncomeTax);
            Assert.AreEqual(1639, paySlip.NetIncome);
            Assert.AreEqual(50, paySlip.SuperAnnuation);
            Assert.AreEqual("01 Jun 2018-30 Jun 2018", paySlip.PayPeriod);
        }
Beispiel #8
0
        public void Test_GetPayslip_1()
        {
            var payslipController = new PayslipController();

            var employee = new Employee()
            {
                FirstName    = "Uvika",
                LastName     = "Khatri",
                AnnualSalary = 60050,
                StartDate    = new DateTime(2018, 03, 01),
                SuperRate    = 9
            };

            var paySlip = (payslipController.CreatePaySlip(employee) as OkNegotiatedContentResult <Payslip>).Content;

            Assert.IsNotNull(paySlip);
            Assert.AreEqual(5004, paySlip.GrossIncome);
            Assert.AreEqual(922, paySlip.IncomeTax);
            Assert.AreEqual(4082, paySlip.NetIncome);
            Assert.AreEqual(450, paySlip.SuperAnnuation);
            Assert.AreEqual("01 Mar 2018-31 Mar 2018", paySlip.PayPeriod);
        }