public void GetDataFromInvoicesAndEmployeesFakes() { // Arrange var invoiceRepository = new FakeInvoiceRepository(); var employeeRepository = new FakeEmployeeRepository(); var service = new ExtractionService(invoiceRepository, employeeRepository, Console.Out); // Act ExtractionResult result = service.Extract(); // Assert Assert.That(invoiceRepository.WasCalled); Assert.That(employeeRepository.WasCalled == false); }
public void GetDataFromInvoicesAndEmployees() { // Arrange var invoiceRepository = new Mock <IInvoiceRepository>(); var employeeRepository = new Mock <IEmployeeRepository>(); invoiceRepository.Setup(m => m.ListInvoices()).Returns(new DataTable()); var service = new ExtractionService(invoiceRepository.Object, employeeRepository.Object); // Act var result = service.Extract(); // Assert invoiceRepository.Verify(i => i.ListInvoices(), Times.Exactly(1)); employeeRepository.Verify(e => e.ListEmployees(), Times.Never()); }
public void GetDataFromInvoicesAndEmployeesMocks() { // Arrange var invoiceRepository = new Mock <IInvoiceRepository>(); var employeeRepository = new Mock <IEmployeeRepository>(); invoiceRepository.Setup(m => m.List(It.IsAny <DateTime>())).Returns(new List <Invoice>()); var service = new ExtractionService(invoiceRepository.Object, employeeRepository.Object, Console.Out); // Act ExtractionResult result = service.Extract(); // Assert invoiceRepository.VerifyAll(); employeeRepository.Verify(e => e.List(), Times.Never()); }