public void TreeService_Add_Throws_On_Null_Tree() { //Arrange _service = new TreeService(_mockUnitOfWork.Object); //Act,Assert Assert.Throws<ArgumentNullException>(() => _service.Add(null)); }
public void TreeService_Add_Calls_Repsoitory_Add_Method_With_The_Same_Tree_Object_It_Recieved() { // Create test data var newTree = new Tree { Name = "Foo" }; //SetUp Mock var mockRepository = new Mock<IRepository<Tree>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Tree>()).Returns(mockRepository.Object); //Arrange _service = new TreeService(_mockUnitOfWork.Object); //Act _service.Add(newTree); //Assert mockRepository.Verify(r => r.Add(newTree)); }
public void Register(Tree tree) { _service.Add(tree); }
public void TreeService_Add_Calls_UnitOfWork_Commit_Method() { // Create test data var newTree = new Tree { Name = "Foo" }; //Create Mock var mockRepository = new Mock<IRepository<Tree>>(); _mockUnitOfWork.Setup(d => d.GetRepository<Tree>()).Returns(mockRepository.Object); //Arrange _service = new TreeService(_mockUnitOfWork.Object); //Act _service.Add(newTree); //Assert _mockUnitOfWork.Verify(db => db.Commit()); }