public void GetById_Should_NotReturnAdvert_IfThereIsNoVehicleModelYolo() { var mockedRepository = new Mock <IRepository <VehicleModel> >(); var vehicleModelService = new VehicleModelServices(mockedRepository.Object); mockedRepository.Setup(rep => rep.GetById(0)).Returns(() => null); Assert.IsNull(vehicleModelService.GetById(0)); }
public void GetById_ShouldThrowNullReferenceException_IfVehicleModelIsNull() { var mockedRepository = new Mock <IRepository <VehicleModel> >(); var vehicleModelService = new VehicleModelServices(mockedRepository.Object); Mock <VehicleModel> vehicleModelWithId = null; Assert.Throws <NullReferenceException>(() => vehicleModelService.GetById(vehicleModelWithId.Object.Id)); }
public void GetById_Should_Work_IfCalledWithValidParams() { var mockedRepository = new Mock <IRepository <VehicleModel> >(); var vehicleModelService = new VehicleModelServices(mockedRepository.Object); var vehicleModelWithId = new Mock <VehicleModel>(); mockedRepository.Setup(rep => rep.GetById(vehicleModelWithId.Object.Id)).Returns(() => vehicleModelWithId.Object); Assert.AreEqual(vehicleModelService.GetById(vehicleModelWithId.Object.Id), vehicleModelWithId.Object); }
public void GetById_Should_ReturnTheProperVehicleModelWithId_IfCalled() { var mockedRepository = new Mock <IRepository <VehicleModel> >(); var vehicleModelService = new VehicleModelServices(mockedRepository.Object); var vehicleModelWithId = new Mock <VehicleModel>(); mockedRepository.Setup(rep => rep.GetById(vehicleModelWithId.Object.Id)).Returns(() => vehicleModelWithId.Object); Assert.IsInstanceOf <VehicleModel>(vehicleModelService.GetById(vehicleModelWithId.Object.Id)); }
public void GetById_Should_BeCalledOnce_IfParamsAreValid() { var mockedRepository = new Mock <IRepository <VehicleModel> >(); var vehicleModelService = new VehicleModelServices(mockedRepository.Object); var vehicleModel = new Mock <VehicleModel>(); vehicleModelService.GetById(vehicleModel.Object.Id); mockedRepository.Verify(rep => rep.GetById(vehicleModel.Object.Id), Times.Once); }
public void GetById_Should_ReturnTheCorrectVehicleModel_IfCalled() { var mockedRepository = new Mock <IRepository <VehicleModel> >(); var vehicleModelService = new VehicleModelServices(mockedRepository.Object); var vehicleModel = new Mock <VehicleModel>(); var secondVehicleModel = new Mock <VehicleModel>(); mockedRepository.Setup(rep => rep.GetById(vehicleModel.Object.Id)).Returns(() => vehicleModel.Object); Assert.AreNotEqual(vehicleModelService.GetById(vehicleModel.Object.Id), secondVehicleModel.Object); }