public void GetAutomobile_ShouldCallRepository_GetAutomobileWithCorrectVIN() { var _mockRepo = new Mock <IGasAutomobileRepository>(); var controller = new GasAutomobileController(_mockRepo.Object); var VIN = "123"; controller.GetAutomobile(VIN); _mockRepo.Verify(m => m.GetAutomobile(VIN)); }
public void GetAutomobile_ShouldReturnNotFound_GivenNoAutoReturnedFromRepo() { var controller = new GasAutomobileController(_mockRepo.Object); var vin = "1"; _mockRepo.Setup(m => m.GetAutomobile(vin)).Returns((GasAutomobile)null); IHttpActionResult result = controller.GetAutomobile(vin); Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public void GetAutomobile_ShouldReturnAuto_GivenAutoReturnedFromRepo() { var vin = "1"; var auto = new GasAutomobile() { VIN = vin }; var controller = new GasAutomobileController(_mockRepo.Object); _mockRepo.Setup(m => m.GetAutomobile(vin)).Returns(auto); IHttpActionResult actionResult = controller.GetAutomobile(vin); var result = actionResult as OkNegotiatedContentResult <GasAutomobile>; Assert.IsNotNull(result); Assert.IsNotNull(result.Content); Assert.AreEqual(auto, result.Content); }