public void MultimediaLinkService_Add_Throws_On_Null_MultimediaLink() { //Arrange _mockUnitOfWork = new Mock<IUnitOfWork>(); _service = new MultimediaLinkService(_mockUnitOfWork.Object); //Assert Assert.Throws<ArgumentNullException>(() => _service.Add(null)); }
public void MultimediaLinkService_Add_Calls_Repsoitory_Add_Method_With_The_Same_MultimediaLink_Object_It_Recieved() { // Create test data var newMultimediaLink = new MultimediaLink { File = "Foo" }; //Create Mock _mockUnitOfWork = new Mock<IUnitOfWork>(); var mockRepository = new Mock<IRepository<MultimediaLink>>(); _mockUnitOfWork.Setup(d => d.GetRepository<MultimediaLink>()).Returns(mockRepository.Object); //Arrange _service = new MultimediaLinkService(_mockUnitOfWork.Object); //Act _service.Add(newMultimediaLink); //Assert mockRepository.Verify(r => r.Add(newMultimediaLink)); }
public void MultimediaLinkService_Add_Calls_UnitOfWork_Commit_Method() { // Create test data var newMultimediaLink = new MultimediaLink { File = "Foo" }; //Create Mock _mockUnitOfWork = new Mock<IUnitOfWork>(); var mockRepository = new Mock<IRepository<MultimediaLink>>(); _mockUnitOfWork.Setup(d => d.GetRepository<MultimediaLink>()).Returns(mockRepository.Object); //Arrange _service = new MultimediaLinkService(_mockUnitOfWork.Object); //Act _service.Add(newMultimediaLink); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }