public void GetAllAutomobiles_ShouldCallRepositoryGetAutomobiles() { var controller = new ElectricAutomobileController(_mockRepo.Object); controller.GetAllAutomobiles(); _mockRepo.Verify(m => m.GetAutomobiles()); }
public void GetAllAutomobiles_ShouldReturnEmptyList_GivenNoAutosReturnedFromRepo() { var controller = new ElectricAutomobileController(_mockRepo.Object); _mockRepo.Setup(m => m.GetAutomobiles()).Returns((List <ElectricAutomobile>)null); var result = controller.GetAllAutomobiles(); Assert.IsNotNull(result); Assert.AreEqual(0, result.Count()); }
public void GetAllAutomobiles_ShouldReturnAuto_GivenAutosReturnedFromRepo() { var vin = "1"; var auto = new ElectricAutomobile() { VIN = vin }; var autos = new List <ElectricAutomobile>(); autos.Add(auto); var controller = new ElectricAutomobileController(_mockRepo.Object); _mockRepo.Setup(m => m.GetAutomobiles()).Returns(autos); var result = controller.GetAllAutomobiles(); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); Assert.AreEqual(auto, result.First()); }