public void PlaneService_DeleteEntity_IsInvoked() { //Arrange var planePartRepository = new Mock <IPlanePartRepository>(); planePartRepository.Setup(a => a.DeletePlanePart(It.Is <PlanePart>(x => x == part))).Verifiable(); uow = new UnitOfWork(planeRepository.Object, userRepository.Object, planePartRepository.Object); partService = new PlanePartService(uow, new DtoProfile()); //Act partService.DeletePlanePart(partDto); //Assert planePartRepository.Verify(h => h.DeletePlanePart(It.Is <PlanePart>(r => r != null))); }
public void PlaneService_DeleteEntity_Exception() { //Arrange var planePartRepository = new Mock <IPlanePartRepository>(); planePartRepository.Setup(a => a.DeletePlanePart(null)).Throws(new ArgumentNullException("part", "Null argument was passed as a parameter")).Verifiable(); uow = new UnitOfWork(planeRepository.Object, userRepository.Object, planePartRepository.Object); partService = new PlanePartService(uow, new DtoProfile()); //Act partService.DeletePlanePart(null); //Assert var ex = Assert.Throws <ArgumentNullException>(() => planePartRepository.Object.DeletePlanePart(null)); Assert.That(ex.Message, Is.EqualTo("Null argument was passed as a parameter (Parameter 'part')")); }