public void DeleteDroneWithIdLowerThan1ThrowsException() { var droneRepo = new Mock <IDroneRepository>(); IDroneService droneService = new DroneService(droneRepo.Object); var drone = new Drone() { Id = 0, Manufacturer = new Manufacturer() { Id = 1, Name = "Phantom", Drones = new List <Drone>() { new Drone() } }, ProductName = "B15", Price = 500, Details = "Handsome", ImageURL = "www.imgUrl.com" }; var e = Assert.Throws <ArgumentException>(() => droneService.Delete(drone.Id)); Assert.Equal("The Id entered has to be at least 1", e.Message); }
public void DeleteDroneEnsureRepositoryIsCalled() { var droneRepo = new Mock <IDroneRepository>(); IDroneService droneService = new DroneService(droneRepo.Object); var isCalled = false; var drone = new Drone() { Id = 1, Manufacturer = new Manufacturer() { Id = 1, Name = "Phantom", Drones = new List <Drone>() { new Drone() } }, ProductName = "B15", Price = 500, Details = "Handsome", ImageURL = "www.imgUrl.com" }; droneRepo.Setup(x => x.Delete(drone.Id)).Callback(() => isCalled = true).Returns(new Drone() { Id = 1, Manufacturer = new Manufacturer() { Id = 1, Name = "Phantom", Drones = new List <Drone>() { new Drone() } }, ProductName = "B15", Price = 500, Details = "Handsome", ImageURL = "www.imgUrl.com" }); droneService.Delete(drone.Id); Assert.True(isCalled); }