Ejemplo n.º 1
0
        public async Task GetCarModelByIdTest()
        {
            var car = CarDataSeeder.GetEntities().First();
            await _carRepository.AddAsync(car);

            Assert.NotNull(await _carModelService.GetCarModelByIdAsync(1));
        }
Ejemplo n.º 2
0
        public async Task CalculateTotalPurchasePriceTest()
        {
            var car = CarDataSeeder.GetEntities().First();
            await _carRepository.AddAsync(car);

            var carModel = (await _carModelService.GetCarModelsAsync()).Last();

            Assert.Equal(1100, _carModelService.CalculateTotalPurchasePrice(carModel));
        }
Ejemplo n.º 3
0
        public async Task GetCarModelsAdminOverviewTest()
        {
            var cars = CarDataSeeder.GetEntities().ToArray();
            await _carRepository.AddAsync(cars[0]);

            await _carRepository.AddAsync(cars[1]);

            Assert.Equal(2, cars.Count());
        }
Ejemplo n.º 4
0
        public CarRepositoryTests()
        {
            _carRepository = new EfRepository <Car>(applicationDbContext, new CarValidator());

            var cars = CarDataSeeder.GetEntities().ToArray();

            _car1 = cars[0];
            _car2 = cars[1];
        }
Ejemplo n.º 5
0
        public async Task SetSalesDate()
        {
            var car = CarDataSeeder.GetEntities().First();
            await _carRepository.AddAsync(car);

            var result = await _carsController.SetSalesDate(1, DateTime.Today);

            Assert.IsAssignableFrom <OkObjectResult>(result);
            Assert.Equal(DateTime.Today, (await _carRepository.GetAllAsync()).Last().SaleDate);
        }
Ejemplo n.º 6
0
        public async Task RemoveImageTest()
        {
            var car = CarDataSeeder.GetEntities().First();
            await _carRepository.AddAsync(car);

            var result = await _carsController.RemoveImage(1);

            Assert.IsAssignableFrom <JsonResult>(result);
            Assert.Empty((await _carRepository.GetAllAsync()).Last().Images);
        }
Ejemplo n.º 7
0
        public async Task EditCarTest()
        {
            var car = CarDataSeeder.GetEntities().First();
            await _carRepository.AddAsync(car);

            var result = await _carsController.EditCar(1);

            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.NotNull(viewResult.Model);
        }
Ejemplo n.º 8
0
        public async Task CarDetailsTest()
        {
            var car = CarDataSeeder.GetEntities().First();
            await _carRepository.AddAsync(car);

            var result = await _carsController.CarDetails(1);

            var viewResult = Assert.IsAssignableFrom <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <CarModel>(viewResult.Model);

            Assert.NotNull(model);
        }
Ejemplo n.º 9
0
        public async Task IndexTest()
        {
            var cars = CarDataSeeder.GetEntities().ToArray();
            await _carRepository.AddAsync(cars[0]);

            await _carRepository.AddAsync(cars[1]);

            var result = await _carsController.Index();

            var viewResult = Assert.IsAssignableFrom <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <CarOverviewModel>(viewResult.Model);

            Assert.Equal(2, model.CarsForSale.Count());
        }
Ejemplo n.º 10
0
        public async Task SetAsThumbnailTest()
        {
            var car = CarDataSeeder.GetEntities().First();

            car.Images.Add(new Image {
                File = Convert.FromBase64String(FileDataSeeder.GetBase64Images().Last()), ImageType = "png"
            });
            await _carRepository.AddAsync(car);

            var result = await _carsController.SetAsThumbnail(2, 1);

            Assert.IsAssignableFrom <JsonResult>(result);
            Assert.Equal(car.ThumbnailImage.File, (await _carRepository.GetByIdAsync(1)).ThumbnailImage.File);
        }
Ejemplo n.º 11
0
        public async Task OverviewTest()
        {
            var cars = CarDataSeeder.GetEntities().ToArray();
            await _carRepository.AddAsync(cars[0]);

            await _carRepository.AddAsync(cars[1]);

            var result = await _carsController.Overview();

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <CarModel> >(viewResult.Model);

            Assert.Equal(2, model.Count());
        }
Ejemplo n.º 12
0
        public async Task GetCarOverviewModelTest()
        {
            var car = CarDataSeeder.GetEntities().First();

            car.ShowCase = false;
            await _carRepository.AddAsync(car);

            car.Id       = 0;
            car.ShowCase = true;
            car.SaleDate = DateTime.Today.AddDays(-(ConfigurationConstants.RecentlySoldMaxDays + 1));
            await _carRepository.AddAsync(car);

            car.Id       = 0;
            car.ShowCase = false;
            car.SaleDate = DateTime.Today;
            await _carRepository.AddAsync(car);

            var carOverviewModel = await _carModelService.GetCarOverviewModelAsync();

            Assert.Single(carOverviewModel.CarsForSale);
            Assert.Single(carOverviewModel.CarsShowcase);
            Assert.Single(carOverviewModel.CarsRecentlySold);
        }
Ejemplo n.º 13
0
 public CarServiceTests()
 {
     _carRepository = new EfRepository <Car>(applicationDbContext, new CarValidator());
     _carService    = new CarService(_carRepository);
     _car           = CarDataSeeder.GetEntities().First();
 }