示例#1
0
        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);
        }
示例#2
0
        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>;
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }