Esempio n. 1
0
        public async Task GetCurrentCarAsyncTest()
        {
            var options       = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString());
            var carRepository = new EfDeletableEntityRepository <Car>(new ApplicationDbContext(options.Options));

            var service = new AdService(carRepository);

            var inputModel = new CreateAdInputModel
            {
                Cc               = 1,
                Color            = 0,
                Condition        = Condition.New,
                Door             = Doors.Three,
                EuroStandart     = EuroStandart.Euro1,
                Extras           = "4x4",
                Fuel             = Fuel.Diesel,
                Gearbox          = Gearbox.Automatic,
                Hp               = 1,
                ImgsPaths        = GlobalConstants.DefaultImgCar,
                Km               = 100,
                Location         = Location.Sofia,
                Make             = Make.Audi,
                Model            = "test",
                Modification     = "test",
                MoreInformation  = "test test",
                Price            = 100,
                Type             = Types.Convertible,
                TypeOfVeichle    = TypeOfVeichle.Car,
                YearOfProduction = "01.1999",
            };

            await service.CreateAdAsync(inputModel, "1");

            var car = await carRepository.All().FirstOrDefaultAsync(x => x.Model == "test");

            var carId        = car.Id;
            var carByService = await service.GetCurrentCarAsync(carId);

            Assert.Same(car, carByService);
            Assert.Equal(car.Id, carByService.Id);
        }