Ejemplo n.º 1
0
        public string FormatErrorHeader(ImportFileDetail importFileDetail)
        {
            string errorHeader = @"Unable to process record - " + importFileDetail.FirstName + "," + importFileDetail.LastName + ","
                                 + importFileDetail.AnnualIncomeString + ","
                                 + importFileDetail.SuperRateString + "," + importFileDetail.MonthStarting;

            return(errorHeader);
        }
        public void CheckEmployeePayslipOutput()
        {
            string expectedResult = "EmpPayslipOutput1 EmpPayslipOutput1,01 March - 31 March,833,0,833,75";

            Assert.IsTrue(employeePaySlipOutput.FileHasErrors() == false, "Import File has returned some errors.");
            ImportFileDetail importFileDetail = employeePaySlipOutput.ImportFileDetails.FirstOrDefault(impFileDetail => impFileDetail.FirstName == "EmpPayslipOutput1");

            Assert.IsTrue(importFileDetail != null, "Failed to retrieve a matching record for employee with FirstName EmpPayslipOutput1");
            string actualResult = importFileDetail.FormatPayslipOutput();

            Assert.IsTrue(expectedResult == actualResult, string.Format("Expected Result : {0}. Actual Result : {1}", expectedResult.ToString(), actualResult.ToString()));
        }
        public void ImportRecordWithInvalidLastName()
        {
            ImportFileDetail importFileDetail    = invalidImportRecord.ImportFileDetails.FirstOrDefault(impFileDetail => string.IsNullOrEmpty(impFileDetail.LastName));
            string           expectedErrorHeader = invalidImportRecord.FormatErrorHeader(importFileDetail);

            Assert.IsTrue(importFileDetail != null, "Failed to retrieve a matching record for an employee with a blank Last Name");

            ErrorDetail errorDetail = invalidImportRecord.Errors.FirstOrDefault(err => err.ErrorHeader == expectedErrorHeader);

            Assert.IsTrue(errorDetail != null, "Failed to retrieve a matching error detail");
            Assert.IsTrue(expectedErrorHeader == errorDetail.ErrorHeader, string.Format("Expected Error Header Result : {0}. Actual Result : {1}", expectedErrorHeader.ToString(), errorDetail.ErrorHeader));
            Assert.IsTrue(expectedLastNameErrorBody == errorDetail.ErrorBody, string.Format("Expected Error Body Result : {0}. Actual Result : {1}", expectedLastNameErrorBody.ToString(), errorDetail.ErrorBody));
        }
        public void ImportRecordWithAnOutOfRangeSuperRate()
        {
            ImportFileDetail importFileDetail    = invalidImportRecord.ImportFileDetails.FirstOrDefault(impFileDetail => impFileDetail.FirstName == "InvalidSuperRate");
            string           expectedErrorHeader = invalidImportRecord.FormatErrorHeader(importFileDetail);

            Assert.IsTrue(importFileDetail != null, "Failed to retrieve a matching record for an employee with an out of range Super Rate");

            ErrorDetail errorDetail = invalidImportRecord.Errors.FirstOrDefault(err => err.ErrorHeader == expectedErrorHeader);

            Assert.IsTrue(errorDetail != null, "Failed to retrieve a matching error detail");
            Assert.IsTrue(expectedErrorHeader == errorDetail.ErrorHeader, string.Format("Expected Error Header Result : {0}. Actual Result : {1}", expectedErrorHeader.ToString(), errorDetail.ErrorHeader));
            Assert.IsTrue(expectedSuperRateOutOfRangeErrorBody == errorDetail.ErrorBody, string.Format("Expected Error Body Result : {0}. Actual Result : {1}", expectedSuperRateOutOfRangeErrorBody.ToString(), errorDetail.ErrorBody));
        }
        public void ImportRecordWithInvalidMonthStarting()
        {
            ImportFileDetail importFileDetail    = invalidImportRecord.ImportFileDetails.FirstOrDefault(impFileDetail => impFileDetail.MonthStarting == "01 March - 29-March");
            string           expectedErrorHeader = invalidImportRecord.FormatErrorHeader(importFileDetail);

            Assert.IsTrue(importFileDetail != null, "Failed to retrieve a matching record for an employee with an invalid Month Starting");

            ErrorDetail errorDetail = invalidImportRecord.Errors.FirstOrDefault(err => err.ErrorHeader == expectedErrorHeader);

            Assert.IsTrue(errorDetail != null, "Failed to retrieve a matching error detail");
            Assert.IsTrue(expectedErrorHeader == errorDetail.ErrorHeader, string.Format("Expected Error Header Result : {0}. Actual Result : {1}", expectedErrorHeader.ToString(), errorDetail.ErrorHeader));
            Assert.IsTrue(expectedMonthStartingErrorBody == errorDetail.ErrorBody, string.Format("Expected Error Body Result : {0}. Actual Result : {1}", expectedMonthStartingErrorBody.ToString(), errorDetail.ErrorBody));
        }
        public void CheckIncomeTaxCalculationForTaxBracketOne()
        {
            decimal expectedGrossMonthlyIncome = 833;
            decimal expectedIncomeTax          = 0;
            decimal expectedNetIncome          = 833;
            decimal expectedSuperDeduction     = 75;
            string  employeeFirstName          = "TaxBracket1";

            Assert.IsTrue(taxBracketCalculation.FileHasErrors() == false, "Import File has returned some errors.");
            ImportFileDetail importFileDetail = taxBracketCalculation.ImportFileDetails.FirstOrDefault(impFileDetail => impFileDetail.FirstName == employeeFirstName);

            Assert.IsTrue(importFileDetail != null, string.Format("Failed to retrieve a matching record for employee with FirstName {0}", employeeFirstName));
            Assert.IsTrue(expectedGrossMonthlyIncome == importFileDetail.GrossMonthlyIncome, string.Format("Expected Gross Monthly Income Result : {0}. Actual Result : {1}", expectedGrossMonthlyIncome.ToString(), importFileDetail.GrossMonthlyIncome.ToString()));
            Assert.IsTrue(expectedIncomeTax == importFileDetail.IncomeTax, string.Format("Expected Income Tax Result : {0}. Actual Result : {1}", expectedIncomeTax.ToString(), importFileDetail.IncomeTax.ToString()));
            Assert.IsTrue(expectedNetIncome == importFileDetail.NetIncome, string.Format("Expected Net Income Result : {0}. Actual Result : {1}", expectedNetIncome.ToString(), importFileDetail.NetIncome.ToString()));
            Assert.IsTrue(expectedSuperDeduction == importFileDetail.SuperDeduction, string.Format("Expected Super Deduction Result : {0}. Actual Result : {1}", expectedSuperDeduction.ToString(), importFileDetail.SuperDeduction.ToString()));
        }