public void GetAllReturnsAllRoutesAsIQueryable() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <Route>(new ApplicationDbContext(options.Options)); repository.AddAsync(new Route { StartPoint = "София", EndPoint = "Пловдив", Distance = 225 }); repository.AddAsync(new Route { StartPoint = "София", EndPoint = "Хасково", Distance = 267 }); repository.AddAsync(new Route { StartPoint = "София", EndPoint = "Варна", Distance = 441 }); repository.SaveChangesAsync(); var routesService = new RoutesService(repository); AutoMapperConfig.RegisterMappings(typeof(RouteViewModel).Assembly); var routes = routesService.GetAll <RouteViewModel>(); Assert.Equal(3, routes.Count()); }
public void GetAllReturnsAllRoutesAsCollectionOfSelectListItem() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <Route>(new ApplicationDbContext(options.Options)); repository.AddAsync(new Route { StartPoint = "София", EndPoint = "Пловдив", Distance = 225 }); repository.AddAsync(new Route { StartPoint = "София", EndPoint = "Хасково", Distance = 267 }); repository.AddAsync(new Route { StartPoint = "София", EndPoint = "Варна", Distance = 441 }); repository.SaveChangesAsync(); var routesService = new RoutesService(repository); var routes = routesService.GetAll(); Assert.Equal(3, routes.Count()); }