public async Task AddAsyncShouldCreateCar() { var options = new DbContextOptionsBuilder <NeedForCarsDbContext>() .UseInMemoryDatabase("CreateCarDb") .Options; var context = new NeedForCarsDbContext(options); var makesService = new MakesService(context); var modelsService = new ModelsService(context, makesService); var generationsService = new GenerationsService(context, modelsService); var carsService = new CarsService(context, generationsService); var make = new Make { Name = "Make", Description = "Desc" }; await context.Makes.AddAsync(make); await context.SaveChangesAsync(); var model = new Model { MakeId = make.Id, Name = "Model" }; await context.Models.AddAsync(model); await context.SaveChangesAsync(); var generation = new Generation { ModelId = model.Id, BodyType = Models.Enums.BodyType.Convertible, Name = "Name", Seats = 5, Description = "Desc" }; await context.Generations.AddAsync(generation); await context.SaveChangesAsync(); var engine = new Engine { Name = "Name1", FuelType = Models.Enums.FuelType.Diesel, MaxHP = 100, Creator = "Creator" }; await context.AddAsync(engine); await context.SaveChangesAsync(); var car = new Car { GenerationId = generation.Id, EngineId = engine.Id, Transmission = Models.Enums.Transmission.Automatic, DriveWheel = Models.Enums.DriveWheel.AllWheelDrive, BeginningOfProductionYear = 2000, BeginningOfProductionMonth = 1 }; await carsService.AddAsync(car); var result = await context.Cars.CountAsync(); Assert.Equal(1, result); }