public async Task Update_CorrectData_RentalCreated() { var repository = MockRentalsRepository(); var service = new RentalsService(repository.Object); var rental = new Rental { Id = 1, BookId = 1, CustomerId = Guid.NewGuid(), StartDate = new DateTime(2012, 12, 12) }; await service.Update(rental); repository.Verify(repository => repository.Update(rental), Times.AtLeastOnce); }
public async Task Update_InvalidData_ExceptionThrown(int id, int bookId, Guid customerId, DateTime startDate, DateTime endDate) { var repository = MockRentalsRepository(); var service = new RentalsService(repository.Object); var rental = new Rental { Id = id, BookId = bookId, CustomerId = customerId, StartDate = startDate, EndDate = endDate }; try { await service.Update(rental); } catch (ArgumentException) { Assert.Pass(); } Assert.Fail(); }