Beispiel #1
0
        public async Task UpdateAsync_WithNonExistentId_ReturnsFalse()
        {
            // Arrange
            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            context.CarModels.AddRange(
                new CarModel
            {
                Model = "OtherModel1"
            },
                new CarModel
            {
                Model = "OtherModel2"
            });

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            var serviceModel = new CarModelServiceModel
            {
                Id    = Guid.NewGuid().ToString(),
                Model = "TestName"
            };

            // Act
            var result = await modelsService.UpdateAsync(serviceModel);

            // Assert
            Assert.False(result);
        }
Beispiel #2
0
        public async Task GetAllByManufacturerAsync_WithNullManufacturerId_ReturnsNull()
        {
            // Arrange
            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            context.CarModels.Add(new CarModel
            {
                Model        = "OtherModel",
                Manufacturer = new CarManufacturer
                {
                    Name = "OtherManufacturer"
                }
            });

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            // Act
            var result = await modelsService.GetAllByManufacturerAsync(null);

            // Assert
            Assert.Null(result);
        }
Beispiel #3
0
        public async Task AddAsyncShouldCreateModel()
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("CreateModelDb")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService  = new MakesService(context);
            var modelsService = new ModelsService(context, makesService);

            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 modelsService.AddAsync(model);

            await context.SaveChangesAsync();

            var result = context.Models.Count();

            Assert.Equal(1, result);
        }
Beispiel #4
0
        public async Task GetAllGenericShouldWork()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "GetAllGenericShouldWork").Options;
            var dbContext = new ApplicationDbContext(options);

            dbContext.Models.Add(new Model()
            {
                Name = "1", MakeId = 1
            });
            dbContext.Models.Add(new Model()
            {
                Name = "2", MakeId = 2
            });
            dbContext.Models.Add(new Model()
            {
                Name = "3", MakeId = 3
            });
            await dbContext.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

            Assert.Equal(3, service.GetAll <ModelsReturnModel>().Count());
        }
Beispiel #5
0
        public async Task DeleteAsync_WithNonExistentId_ReturnsFalse()
        {
            // Arrange
            var testId = Guid.NewGuid().ToString();

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            context.CarModels.AddRange(
                new CarModel
            {
                Model = "OtherModel1"
            },
                new CarModel
            {
                Model = "OtherModel2"
            });

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            // Act
            var result = await modelsService.DeleteAsync(testId);

            // Assert
            Assert.False(result);

            var dbCount = await context.CarModels.CountAsync();

            Assert.Equal(2, dbCount);
        }
Beispiel #6
0
        public async Task CreateAsync_WithValidModel_WorksCorrectly()
        {
            // Arrange
            const string testName = "TestName";

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            var serviceModel = new CarModelServiceModel
            {
                Model = testName
            };

            // Act
            var result = await modelsService.CreateAsync(serviceModel);

            // Assert
            Assert.True(result);

            var addedToDb = await context.CarModels.AnyAsync(m => m.Model == testName);

            Assert.True(addedToDb);
        }
 public ModelPredictorService(ModelsService modelsService, IDataDirectoryService dataDirectoryService)
 {
     _modelsService        = modelsService;
     _dataDirectoryService = dataDirectoryService;
     _producerConsumer     = new ProducerConsumer <Action>(1, ConsumeAction);
     //_producerConsumer.Add(() => _y = Py.GIL());
     //_producerConsumer.Start();
 }
Beispiel #8
0
        public async Task GetAllForModelShouldReturnAllGenerationsForModel()
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("GetAllForModelGenerationDb")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService       = new MakesService(context);
            var modelsService      = new ModelsService(context, makesService);
            var generationsService = new GenerationsService(context, modelsService);

            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 generation1 = new Generation
            {
                ModelId     = model.Id,
                BodyType    = Models.Enums.BodyType.Convertible,
                Name        = "Name",
                Seats       = 5,
                Description = "Desc"
            };
            var generation2 = new Generation
            {
                ModelId     = model.Id,
                BodyType    = Models.Enums.BodyType.Convertible,
                Name        = "Name2",
                Seats       = 5,
                Description = "Desc"
            };
            await context.Generations.AddAsync(generation1);

            await context.Generations.AddAsync(generation2);

            await context.SaveChangesAsync();

            var result = generationsService.GetAllForModel(model.Id).Count();

            Assert.Equal(2, result);
        }
Beispiel #9
0
        public void GetModelByNameShouldThrowNullExceptionForInvalidName(string name)
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddAsyncShouldThrowNullExceptionForInvalidName").Options;
            var dbContext  = new ApplicationDbContext(options);
            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

            Assert.Throws <ArgumentNullException>(() => service.GetModelByName(name));
        }
Beispiel #10
0
        public async Task AddAsyncShouldThrowNullExceptionForInvalidMake()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddAsyncShouldThrowNullExceptionForInvalidMake").Options;
            var dbContext  = new ApplicationDbContext(options);
            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

            await Assert.ThrowsAsync <ArgumentNullException>(() => service.AddAsync("M5", null));
        }
        private IModelsService GetModelsService()
        {
            var dbContext = this.GetUseInMemoryDbContext().GetAwaiter().GetResult();

            var modelsRepository = new EfRepository <Model>(dbContext);
            var carsRepository   = new EfDeletableEntityRepository <Car>(dbContext);

            var service = new ModelsService(modelsRepository, carsRepository);

            return(service);
        }
Beispiel #12
0
        private async Task <IModelsService> GetModelsService()
        {
            var dbContext = await this.GetUseInMemoryDbContext();

            var carsRepository   = new EfDeletableEntityRepository <Car>(dbContext);
            var modelsRepository = new EfRepository <Model>(dbContext);

            var service = new ModelsService(modelsRepository, carsRepository);

            return(service);
        }
Beispiel #13
0
        public async Task GetModelByNameShouldWork()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "GetModelByNameShouldWork").Options;
            var dbContext  = new ApplicationDbContext(options);
            var repository = new EfDeletableEntityRepository <Model>(dbContext);
            var service    = new ModelsService(repository);

            await service.AddAsync("M5", new Make());

            Assert.Equal("M5", service.GetModelByName("M5").Name);
        }
Beispiel #14
0
        public async Task UpdateAsyncShouldCorrectlyUpdateGeneration()
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("UpdateGenerationDb")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService       = new MakesService(context);
            var modelsService      = new ModelsService(context, makesService);
            var generationsService = new GenerationsService(context, modelsService);

            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();

            generation.Name = "updated";
            await generationsService.UpdateAsync(generation);

            var result = context.Generations.FirstAsync()
                         .Result;

            Assert.Equal("updated", result.Name);
        }
Beispiel #15
0
        public FormMain()
        {
            InitializeComponent();
            lblOperatorName.Text = Program.CurrentUser.OperatorName;
            lblLineID.Text       = $"LINE #{Program.CurrentUser.LineID}";

            testLogService    = new TestLogService();
            modelsService     = new ModelsService();
            testResultService = new TestResultService();

            dataGridViewX1.AutoGenerateColumns = false;
            txtBarcode.Focus();
        }
Beispiel #16
0
        public async Task ExistsShouldReturnCorrectValue(string generationName, bool expected)
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("ExistsGenerationDb")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService       = new MakesService(context);
            var modelsService      = new ModelsService(context, makesService);
            var generationsService = new GenerationsService(context, modelsService);

            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        = "Generation",
                Seats       = 5,
                Description = "Desc"
            };
            await context.Generations.AddAsync(generation);

            await context.SaveChangesAsync();

            var result = generationsService.Exists(model.Id, generationName);

            Assert.Equal(expected, result);
        }
Beispiel #17
0
        public async Task GetAllByManufacturerAsync_WithData_WorksCorrectly()
        {
            // Arrange
            var expectedResults = new[] { "Model1", "Model2", "Model3" }
            .OrderBy(m => m)
            .ToArray();

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            var manufacturer = new CarManufacturer
            {
                Name = "TestManufacturer"
            };

            foreach (var model in expectedResults)
            {
                context.CarModels.Add(new CarModel
                {
                    Model        = model,
                    Manufacturer = manufacturer
                });
            }

            context.CarModels.Add(new CarModel
            {
                Model        = "OtherModel",
                Manufacturer = new CarManufacturer
                {
                    Name = "OtherManufacturer"
                }
            });

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            // Act
            var actualResults = (await modelsService.GetAllByManufacturerAsync(manufacturer.Id))
                                .Select(m => m.Model)
                                .OrderBy(m => m)
                                .ToArray();

            // Assert
            Assert.Equal(expectedResults, actualResults);
        }
Beispiel #18
0
        public async Task ExistsAsync_WithDifferentManufacturer_ReturnsFalse()
        {
            // Arrange
            const string testName = "TestName";

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            var manufacturer = new CarManufacturer
            {
                Name = "TestManufacturer"
            };

            context.CarModels.AddRange(
                new CarModel
            {
                Model        = testName,
                Manufacturer = new CarManufacturer
                {
                    Name = "OtherManufacturer"
                }
            },
                new CarModel
            {
                Model        = "OtherModel",
                Manufacturer = manufacturer
            });

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            var serviceModel = new CarModelServiceModel
            {
                Model          = testName,
                ManufacturerId = manufacturer.Id
            };

            // Act
            var result = await modelsService.ExistsAsync(serviceModel);

            // Assert
            Assert.False(result);
        }
Beispiel #19
0
        public async Task UpdateAsync_WithInvalidModel_DoesNotChange()
        {
            // Arrange
            const string expectedResult = "InitialName";

            var model = new CarModel
            {
                Model = expectedResult
            };

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            context.CarModels.AddRange(
                model,
                new CarModel
            {
                Model = "OtherModel1"
            },
                new CarModel
            {
                Model = "OtherModel2"
            });

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            var serviceModel = new CarModelServiceModel
            {
                Id    = model.Id,
                Model = "a"
            };

            // Act
            var result = await modelsService.UpdateAsync(serviceModel);

            // Assert
            Assert.False(result);

            var actualResult = (await context.CarModels.SingleAsync(m => m.Id == model.Id)).Model;

            Assert.Equal(expectedResult, actualResult);
        }
Beispiel #20
0
        public async Task GetAllForMakeShouldReturnAllModelsForMake()
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("ModelGetAllDb")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService  = new MakesService(context);
            var modelsService = new ModelsService(context, makesService);

            var make = new Make
            {
                Name        = "Make",
                Description = "Desc"
            };

            await context.Makes.AddAsync(make);

            await context.SaveChangesAsync();

            var model1 = new Model
            {
                Name        = "Model1",
                Description = "Desc",
                MakeId      = make.Id
            };
            var model2 = new Model
            {
                Name        = "Model2",
                Description = "Desc",
                MakeId      = make.Id
            };

            await context.Models.AddAsync(model1);

            await context.Models.AddAsync(model2);

            await context.SaveChangesAsync();

            var result = modelsService.GetAllForMake(make.Id).Count();

            Assert.Equal(2, result);
        }
Beispiel #21
0
        public async Task DeleteAsync_WithCorrectId_WorksCorrectly()
        {
            // Arrange
            const string testName = "TestName";

            var model = new CarModel
            {
                Model = testName
            };

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            context.CarModels.AddRange(
                model,
                new CarModel
            {
                Model = "OtherModel1"
            },
                new CarModel
            {
                Model = "OtherModel2"
            });

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            // Act
            var result = await modelsService.DeleteAsync(model.Id);

            // Assert
            Assert.True(result);

            var existsInDb = await context.CarModels.AnyAsync(m => m.Model == testName);

            Assert.False(existsInDb);

            var dbCount = await context.CarModels.CountAsync();

            Assert.Equal(2, dbCount);
        }
Beispiel #22
0
        public async Task GetAllByManufacturerAsync_WithNonExistentManufacturer_ReturnsEmptyEnumerable()
        {
            // Arrange
            var testId = Guid.NewGuid().ToString();

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            // Act
            var actualResult = (await modelsService.GetAllByManufacturerAsync(testId)).Count();

            // Assert
            const int expectedResult = 0;

            Assert.Equal(expectedResult, actualResult);
        }
        public void DatesToArrayShouldReturnListOfStrings(int density)
        {
            List <PredictionDate> expectedPredictionDate = new List <PredictionDate>();

            expectedPredictionDate.Add(new PredictionDate()
            {
                Time = DateTime.Now
            });
            expectedPredictionDate.Add(new PredictionDate()
            {
                Time = DateTime.MaxValue
            });
            expectedPredictionDate.Add(new PredictionDate()
            {
                Time = DateTime.Today
            });
            expectedPredictionDate.Add(new PredictionDate()
            {
                Time = DateTime.MinValue
            });
            expectedPredictionDate.Add(new PredictionDate()
            {
                Time = DateTime.UtcNow
            });


            List <ForecastEntity> expectedEntity = new List <ForecastEntity>();

            foreach (var date in expectedPredictionDate)
            {
                expectedEntity.Add(new ForecastEntity()
                {
                    PredictionDate = date
                });
            }
            ModelsService models = new ModelsService();

            //Act
            List <string> result = models.DatesToArray(expectedEntity, density);

            //Assert
            Assert.Equal(result.Count, expectedPredictionDate.Count / density);
        }
Beispiel #24
0
        public async Task UpdateAsyncCorrectlyUpdatesEntity()
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("UpdateModelDb")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService  = new MakesService(context);
            var modelsService = new ModelsService(context, makesService);

            var make = new Make
            {
                Name        = "Make",
                Description = "Desc"
            };
            await context.Makes.AddAsync(make);

            await context.SaveChangesAsync();

            var model = new Model
            {
                Name        = "Model1",
                Description = "Desc",
                MakeId      = make.Id
            };
            await context.Models.AddAsync(model);

            await context.SaveChangesAsync();

            model.Name = "newName";

            await modelsService.UpdateAsync(model);

            await context.SaveChangesAsync();

            var result = context.Models
                         .FirstAsync().Result
                         .Name;

            Assert.Equal("newName", result);
        }
Beispiel #25
0
        public async Task DeleteAsync_WithCars_DoesNotDelete()
        {
            // Arrange
            const string testName = "TestName";

            var model = new CarModel
            {
                Model = testName,
                Cars  = new List <Car>
                {
                    new Car
                    {
                        Colour = "Green"
                    }
                }
            };

            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            context.CarModels.Add(model);

            context.SaveChanges();

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            // Act
            var result = await modelsService.DeleteAsync(model.Id);

            // Assert
            Assert.False(result);

            var existsInDb = await context.CarModels.AnyAsync(m => m.Model == testName);

            Assert.True(existsInDb);

            var dbCount = await context.CarModels.CountAsync();

            Assert.Equal(1, dbCount);
        }
Beispiel #26
0
        public async Task CreateAsync_WithInvalidModel_ReturnsFalse()
        {
            // Arrange
            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            var modelsService = new ModelsService(new EfRepository <CarModel>(context));

            var serviceModel = new CarModelServiceModel();

            // Act
            var result = await modelsService.CreateAsync(serviceModel);

            // Assert
            Assert.False(result);

            var dbCount = await context.CarModels.CountAsync();

            Assert.Equal(0, dbCount);
        }
Beispiel #27
0
        public async Task ExistsShouldReturnCorrectValue(string modelName, bool expected)
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("ModelExistsDb")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService  = new MakesService(context);
            var modelsService = new ModelsService(context, makesService);

            var make = new Make
            {
                Name        = "Make",
                Description = "Desc"
            };

            await context.Makes.AddAsync(make);

            await context.SaveChangesAsync();

            var model = new Model
            {
                Name        = "Model1",
                Description = "Desc",
                MakeId      = make.Id
            };

            await context.Models.AddAsync(model);

            await context.SaveChangesAsync();

            var result = modelsService.Exists(make.Id, modelName);

            Assert.Equal(expected, result);
        }
        public void PressureToChartShouldReturnList(int density)
        {
            List <WeatherMain> expecWeatherMain = new List <WeatherMain>();

            expecWeatherMain.Add(new WeatherMain()
            {
                Humidity       = 0,
                Pressure       = 0,
                Temperature    = 0,
                TemperatureMin = 0,
                TemperatureMax = 0,
            });
            expecWeatherMain.Add(new WeatherMain()
            {
                Humidity       = 0,
                Pressure       = 3,
                Temperature    = 0,
                TemperatureMin = 0,
                TemperatureMax = 0,
            });
            expecWeatherMain.Add(new WeatherMain()
            {
                Humidity       = 0,
                Pressure       = 4,
                Temperature    = 0,
                TemperatureMin = 0,
                TemperatureMax = 0,
            });
            expecWeatherMain.Add(new WeatherMain()
            {
                Humidity       = 0,
                Pressure       = 4,
                Temperature    = 0,
                TemperatureMin = 0,
                TemperatureMax = 0,
            });
            expecWeatherMain.Add(new WeatherMain()
            {
                Humidity       = 0,
                Pressure       = 4,
                Temperature    = 0,
                TemperatureMin = 0,
                TemperatureMax = 0,
            });
            expecWeatherMain.Add(new WeatherMain()
            {
                Humidity       = 0,
                Pressure       = 4,
                Temperature    = 0,
                TemperatureMin = 0,
                TemperatureMax = 0,
            });
            expecWeatherMain.Add(new WeatherMain()
            {
                Humidity       = 0,
                Pressure       = 4,
                Temperature    = 0,
                TemperatureMin = 0,
                TemperatureMax = 0,
            });

            List <ForecastEntity> expectedEntity = new List <ForecastEntity>();

            foreach (var weatherMain in expecWeatherMain)
            {
                expectedEntity.Add(new ForecastEntity()
                {
                    WeatherMain = weatherMain
                });
            }
            ModelsService models = new ModelsService();

            //Act
            ChartValues <double> result = models.PressureToChart(expectedEntity, density);

            //Assert
            Assert.Equal(result.Count, expecWeatherMain.Count / density);
        }
Beispiel #29
0
 public ModelsPcbController()
 {
     modelService = new ModelsService();
 }
Beispiel #30
0
        public async Task GetRelatedEntitiesCountShouldReturnCorrectValues()
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("RelatedEntitiesDb_models")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService  = new MakesService(context);
            var modelsService = new ModelsService(context, makesService);

            var make = new Make
            {
                Name        = "Make",
                Description = "Desc"
            };
            await context.Makes.AddAsync(make);

            var model = new Model
            {
                MakeId = make.Id,
                Name   = "Model1",
            };
            await context.Models.AddAsync(model);

            var generation = new Generation
            {
                ModelId = model.Id,
                Name    = "Model1"
            };
            await context.Generations.AddAsync(generation);

            var engine = new Engine
            {
                Name     = "engine",
                MaxHP    = 100,
                FuelType = Models.Enums.FuelType.Diesel,
                Creator  = "creator"
            };
            await context.Engines.AddAsync(engine);

            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 context.Cars.AddAsync(car);

            var user = new NeedForCarsUser
            {
                Email        = "*****@*****.**",
                UserName     = "******",
                PasswordHash = "HASHEDPASSWORD",
                FirstName    = "First",
                LastName     = "Last",
                PhoneNumber  = "1234567890"
            };
            await context.Users.AddAsync(user);

            var userCar = new UserCar
            {
                OwnerId             = user.Id,
                CarId               = car.Id,
                Color               = "color",
                ProductionDateYear  = 2000,
                ProductionDateMonth = 1,
                Mileage             = 0
            };
            await context.UserCars.AddAsync(userCar);

            await context.SaveChangesAsync();

            modelsService.GetRelatedEntitiesCount(model, out int generations, out int cars, out int userCars);

            Assert.True(generations == 1 && cars == 1 && userCars == 1);
        }