public void ConstructorShould_NotThrow_WhenValidArePassedAsParameters() { //Arrange var carsService = new Mock <ICarsService>(); var mapProvider = new Mock <IMapProvider>(); //Act & Assert var x = new CarsGridController(carsService.Object, mapProvider.Object); }
public void DeleteCarsShould_ReturnJSON_WithModelParameter() { //Arrange var carsService = new Mock <ICarsService>(); var mapProvider = new Mock <IMapProvider>(); var sut = new CarsGridController(carsService.Object, mapProvider.Object); var description = "Description"; var model = new CarViewModel() { Description = description }; //Act var result = sut.DeleteCar(model) as JsonResult; var data = result.Data as IList <CarViewModel>; }
public void DeleteCarsShould_CallServiceMethodDelete() { //Arrange var carsService = new Mock <ICarsService>(); var mapProvider = new Mock <IMapProvider>(); var sut = new CarsGridController(carsService.Object, mapProvider.Object); var description = "Description"; var model = new CarViewModel() { Description = description }; //Act sut.DeleteCar(model); //Assert carsService.Verify(c => c.Delete(null), Times.Once); }
public void GetCarsShould_CallMapperProviderMethodGetMapCollection() { //Arrange var carsService = new Mock <ICarsService>(); var mapProvider = new Mock <IMapProvider>(); var sut = new CarsGridController(carsService.Object, mapProvider.Object); var request = new DataSourceRequest(); var cars = new List <Car>(); carsService.Setup(c => c.GetAll()).Returns(new List <Car>(cars).AsQueryable()); var carViewList = new List <CarViewModel>(); mapProvider.Setup(m => m.GetCollection <CarViewModel>(It.IsAny <Object>())).Returns(carViewList); //Act sut.GetCars(request); //Assert mapProvider.Verify(m => m.GetCollection <CarViewModel>(cars), Times.Once); }