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