public void GetCars_Should_Not_Return_Null() { var repo = new CarsRepository(); var cars = repo.GetCars(); Assert.NotNull(cars); }
public void GetCars_Should_Return_4_Items() { var repo = new CarsRepository(); var cars = repo.GetCars(); Assert.Equal(4, cars.Count()); }
public async Task TestGetCarsbyOwner() { using (var transaction = Fixture.Connection.BeginTransaction()) { using (var context = Fixture.CreateContext(transaction)) { using var serviceScope = _serviceProvider.CreateScope(); var appEnvirontent = serviceScope.ServiceProvider.GetRequiredService <IWebHostEnvironment>(); var seed = new SeedData(new VehicleImageRetriever(), appEnvirontent); var userManager = serviceScope.ServiceProvider.GetRequiredService <ICustomUserManager>(); var userRoleManager = serviceScope.ServiceProvider.GetRequiredService <ICustomRoleManager>(); await seed.Initialize(userManager, userRoleManager, context); var carsRepo = new CarsRepository(context); Random rnd = new Random(); var index = rnd.Next(0, context.Users.AsNoTracking().ToHashSet().Count); var owner = context.Users.AsNoTracking().ToList()[index]; var res = await carsRepo.GetCars(owner); Assert.NotNull(res); Assert.IsAssignableFrom <List <Car> >(res); var resJson = JsonConvert.SerializeObject(res); Assert.NotNull(resJson); Assert.IsAssignableFrom <string>(resJson); } } }
public void GetCars_Test() { //Arrange CarsRepository repo = new CarsRepository(); //Act var cars = repo.GetCars(); //Assert Assert.IsNotNull(cars); }
public void TestCarsRepositoryGetCarsMethod() { bool Success = false; var repository = new CarsRepository(); string carBrandName = "test"; AddCarBrand(repository, carBrandName); var selectedCarBrand = GetSelectedCarBrand(repository, carBrandName); long carBrandId = selectedCarBrand.Id; string carBrandModelName = "test"; AddCarModel(repository, carBrandId, carBrandModelName); var selectedCarBrandModel = GetSelectedCarBrandModel(repository, carBrandId, carBrandModelName); long carBrandModelId = selectedCarBrandModel.Id; long? ownerProfileId = null; string carNumber = "test"; var addedCar = AddCar(repository, ownerProfileId, carBrandId, carBrandModelId, carNumber); if (addedCar?.Id == null || addedCar.Id <= 0) { return; } var selectedCar = GetSelectedCar(repository, addedCar.Id); if (selectedCar?.Id == null || selectedCar.Id <= 0) { return; } var carsList = repository.GetCars(); if (carsList != null) { Success = carsList.Count > 0 ? true : false; } DeleteCar(repository, selectedCar.Id); DeleteCarBrand(repository, selectedCarBrand.Id); DeleteCarModel(repository, selectedCarBrandModel.Id); Assert.IsTrue(Success); }
public IEnumerable <Car> Get() { return(repo.GetCars()); }
public IEnumerable <CarData> Get() { var repository = new CarsRepository(); return(repository.GetCars()); }
public IEnumerable <string> Get() { return(_repo.GetCars()); }