Exemplo n.º 1
0
        public CarModelServiceTests()
        {
            _carRepository = new EfRepository <Car>(applicationDbContext, new CarValidator());

            _carModelService = new CarModelService(
                _carRepository,
                new Mapper(
                    new MapperConfiguration(cfg => cfg.AddProfile(new MappingProfile()))),
                new ImageService(
                    new EfRepository <Image>(applicationDbContext, new FileDataValidator <Image>()),
                    new EfRepository <Thumbnail>(applicationDbContext, new FileDataValidator <Thumbnail>()),
                    new ImageFormatResolver()));

            var images = FileDataSeeder.GetBase64Images().ToArray();

            _jObject1      = new JObject();
            _jObject1.data = new JObject(new JProperty("Value", images[0]));
            _jObject1.type = "png";
            _jObject1.size = new JObject(new JProperty("Value", 1000000));

            _jObject2      = new JObject();
            _jObject2.data = new JObject(new JProperty("Value", images[1]));
            _jObject2.type = "png";
            _jObject2.size = new JObject(new JProperty("Value", 2000000));
        }
Exemplo n.º 2
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);
        }