public void CheckIfScootersForVisualizationBySortingTypeAreSortedCorrectly() { var dbContext = new AutomobileDbContext(); var service = new ElectricScootersService(dbContext); var scootersCollection = service.ScootersForVisualization("UploadDate"); var scootersAvailableInDb = dbContext.ElectricScooterOffers.OrderByDescending(x => x.CreatedOn).ToList(); Assert.Equal(scootersCollection.First().Id, scootersAvailableInDb.First().Id); scootersCollection = service.ScootersForVisualization("LowestPrice"); scootersAvailableInDb = dbContext.ElectricScooterOffers.OrderBy(x => x.Price).ToList(); Assert.Equal(scootersCollection.First().Id, scootersAvailableInDb.First().Id); scootersCollection = service.ScootersForVisualization("HighestPrice"); scootersAvailableInDb = dbContext.ElectricScooterOffers.OrderByDescending(x => x.Price).ToList(); Assert.Equal(scootersCollection.First().Id, scootersAvailableInDb.First().Id); scootersCollection = service.ScootersForVisualization("OldestYear"); scootersAvailableInDb = dbContext.ElectricScooterOffers.OrderBy(x => x.Year).ToList(); Assert.Equal(scootersCollection.First().Id, scootersAvailableInDb.First().Id); scootersCollection = service.ScootersForVisualization("NewestYear"); scootersAvailableInDb = dbContext.ElectricScooterOffers.OrderByDescending(x => x.Year).ToList(); Assert.Equal(scootersCollection.First().Id, scootersAvailableInDb.First().Id); }
public void CheckIfScootersForVisualizationByFiltersAreReturningCorrectOffers() { var dbContext = new AutomobileDbContext(); var service = new ElectricScootersService(dbContext); FiltersInputModel filtersInputModel = new FiltersInputModel() { Condition = Condition.New, MinPrice = 100, Make = "All", Model = "-- All --", MaxPrice = 1000000, MinKilometers = 0, MaxKilometers = 1000000, MinMotorPower = 0, MaxMotorPower = 50000 }; var scootersCollection = service.ScootersForVisualization(filtersInputModel); var scootersAvailableInDb = dbContext.ElectricScooterOffers.Where(x => x.Condition == Condition.New && x.Price >= 100); Assert.Equal(scootersCollection.Count(), scootersAvailableInDb.Count()); }
public void CheckIfScootersForVisualizationAreEqualToScootersInDb() { var dbContext = new AutomobileDbContext(); var service = new ElectricScootersService(dbContext); var scootersCollection = service.ScootersForVisualization(); var scootersAvailableInDb = dbContext.ElectricScooterOffers.ToList(); Assert.True(scootersCollection.Count == scootersAvailableInDb.Count); }