Пример #1
0
        void SalaryService_Process_File_Empty_Test(string path, [Frozen] Mock<IOutputWriter> outputWriter, SalaryDataFileProcessor sut)
        {
            //Act
            sut.ProcessFile(HelperMethods.GetTestDataFolder("" + path));

            //Assert output writer is called.
            outputWriter.Verify(x => x.WriteLine(It.IsAny<string>()), Times.Never);
        }
Пример #2
0
        void SalaryFileProcessor_Successful_Test(string line,  [Frozen] Mock<IOutputWriter> outputWriter, [Frozen] Mock<ISalarySlipService> salarySlipService, SalaryDataFileProcessor sut )
        {
            //Assign
            Customer cust = TestStubs.GetCustomer();
            PaySlipVm paySlipVm = TestStubs.GetPaySlipVm(cust.GetFullName(), cust.PayPeriod.GetPayPeriodWithHypen());
            salarySlipService.Setup(x => x.GenerateSalarySlip(cust, TimeFrequency.Monthly)).Returns(paySlipVm);
            AutoMapperExtensions.Build();

            //Act
            sut.ProcessLine(line);

            //Assert income tax calculation is called.
            salarySlipService.Verify(x =>  x.GenerateSalarySlip(It.IsAny<Customer>(), It.IsAny<TimeFrequency>()), Times.Once());
            outputWriter.Verify(x => x.WriteLine(It.IsAny<string>()), Times.Once());
        }
Пример #3
0
        void SalaryService_Process_File_SuccessfulRead_Test(string path, [Frozen] Mock<IOutputWriter> outputWriter, [Frozen] Mock<ISalarySlipService> salarySlipService, SalaryDataFileProcessor sut)
        {
            //Assign
            Customer cust = TestStubs.GetCustomer();
            PaySlipVm paySlipVm = TestStubs.GetPaySlipVm(cust.GetFullName(), cust.PayPeriod.GetPayPeriodWithHypen());
            salarySlipService.Setup(x => x.GenerateSalarySlip(cust, TimeFrequency.Monthly)).Returns(paySlipVm);
            AutoMapperExtensions.Build();

            //Act
            sut.ProcessFile(HelperMethods.GetTestDataFolder("" + path));

            //Assert output writer is called.
            salarySlipService.Verify(x => x.GenerateSalarySlip(It.IsAny<Customer>(), It.IsAny<TimeFrequency>()), Times.AtLeastOnce);
            outputWriter.Verify(x => x.WriteLine(It.IsAny<string>()), Times.AtLeastOnce);
        }