public void CitationService_Add_Throws_On_Null_Citation() { //Arrange _service = new CitationService(_mockUnitOfWork.Object); //Assert Assert.Throws<ArgumentNullException>(() => _service.Add(null)); }
public void CitationService_Add_Calls_Repository_Add_Method_With_The_Same_Citation_Object_It_Recieved() { // Create test data var newCitation = new Citation { Text = "Foo", Page = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Citation>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object); //Arrange _service = new CitationService(_mockUnitOfWork.Object); //Act _service.Add(newCitation); //Assert mockRepository.Verify(r => r.Add(newCitation)); }
public void CitationService_Add_Calls_UnitOfWork_Commit_Method() { // Create test data var newCitation = new Citation { Text = "Foo", Page = "Bar" }; //Create Mock var mockRepository = new Mock<IRepository<Citation>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object); //Arrange _service = new CitationService(_mockUnitOfWork.Object); //Act _service.Add(newCitation); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }