public void FactService_Delete_Calls_UnitOfWork_Commit_Method() { // Create test data var newFact = new Fact { Date = "Foo", Place = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Fact>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Fact>()).Returns(mockRepository.Object); //Arrange _service = new FactService(_mockUnitOfWork.Object); //Act _service.Delete(newFact); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }
public void FactService_Delete_Throws_On_Null_Fact() { //Arrange _service = new FactService(_mockUnitOfWork.Object); //Assert Assert.Throws<ArgumentNullException>(() => _service.Delete(null)); }
public void FactService_Delete_Calls_Repsoitory_Delete_Method_With_The_Same_Fact_Object_It_Recieved() { // Create test data var newFact = new Fact { Date = "Foo", Place = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Fact>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Fact>()).Returns(mockRepository.Object); //Arrange _service = new FactService(_mockUnitOfWork.Object); //Act _service.Delete(newFact); //Assert mockRepository.Verify(r => r.Delete(newFact)); }