public void PlaneService_GetEntity_Null(int id) { //Arrange var planePartRepository = new Mock <IPlanePartRepository>(); planePartRepository.Setup(a => a.GetPlanePart(It.Is <int>(x => x == id))).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 var getPart = partService.GetPlanePart(id); //Assert Assert.Null(getPart); planePartRepository.Verify(a => a.GetPlanePart(It.Is <int>(r => r == id)), Times.Once()); }
public void PlaneService_GetEntity(int id) { //Arrange var planePartRepository = new Mock <IPlanePartRepository>(); planePartRepository.Setup(a => a.GetPlanePart(It.Is <int>(x => x == id))).Returns(part); uow = new UnitOfWork(planeRepository.Object, userRepository.Object, planePartRepository.Object); partService = new PlanePartService(uow, new DtoProfile()); //Act var getPart = partService.GetPlanePart(id); //Assert Assert.NotNull(getPart); Assert.AreEqual(partDto.Name, getPart.Name); planePartRepository.Verify(a => a.GetPlanePart(It.Is <int>(r => r == id)), Times.Once()); }