public void IndividualService_Delete_Calls_UnitOfWork_Commit_Method() { // Create test data var newIndividual = new Individual { FirstName = "Foo", LastName = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Individual>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Individual>()).Returns(mockRepository.Object); //Arrange _service = new IndividualService(_mockUnitOfWork.Object); //Act _service.Delete(newIndividual); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }
public void IndividualService_Delete_Throws_On_Null_Individual() { //Arrange _service = new IndividualService(_mockUnitOfWork.Object); //Assert Assert.Throws<ArgumentNullException>(() => _service.Delete(null)); }
public void IndividualService_Delete_Calls_Repsoitory_Delete_Method_With_The_Same_Individual_Object_It_Recieved() { // Create test data var newIndividual = new Individual { FirstName = "Foo", LastName = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Individual>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Individual>()).Returns(mockRepository.Object); //Arrange _service = new IndividualService(_mockUnitOfWork.Object); //Act _service.Delete(newIndividual); //Assert mockRepository.Verify(r => r.Delete(newIndividual)); }