public TripControllerTests(ControllerFixture fixture) { Context = fixture.Context; TripRepository = fixture.TripRepository; CalendarRepository = fixture.CalendarRepository; CompanyRepository = fixture.CompanyRepository; NeighborhoodRepository = fixture.NeighborhoodRepository; PatternAreaRepository = fixture.PatternAreaRepository; PaymentTypeRepository = fixture.PaymentTypeRepository; VehicleRepository = fixture.VehicleRepository; VehicleTypeRepository = fixture.VehicleTypeRepository; }
public DeploymentControllerTests(ControllerFixture fixture) { Context = fixture.Context; DeploymentRepository = fixture.DeploymentRepository; CalendarRepository = fixture.CalendarRepository; CompanyRepository = fixture.CompanyRepository; NeighborhoodRepository = fixture.NeighborhoodRepository; PlacementReasonRepository = fixture.PlacementReasonRepository; RemovalReasonRepository = fixture.RemovalReasonRepository; VehicleRepository = fixture.VehicleRepository; VehicleTypeRepository = fixture.VehicleTypeRepository; }
public DatabaseFixture() { DbContextOptions <ScootertownDbContext> options; var builder = new DbContextOptionsBuilder <ScootertownDbContext>(); builder.UseInMemoryDatabase("Data"); options = builder.Options; var context = new ScootertownDbContext(options, new VehicleStoreOptions()); Context = context; }
public ControllerFixture() { Mapper.Initialize(cfg => { cfg.AddProfile <DeploymentProfile>(); cfg.AddProfile <TripProfile>(); cfg.AddProfile <CollisionProfile>(); cfg.AddProfile <ComplaintProfile>(); }); DbContextOptions <ScootertownDbContext> options; var builder = new DbContextOptionsBuilder <ScootertownDbContext>(); builder.UseInMemoryDatabase("API"); options = builder.Options; var context = new ScootertownDbContext(options, new VehicleStoreOptions()); var cache = new Mock <IMemoryCache>(); var entry = new Mock <ICacheEntry>(); int expectedKey = 1; object expectedValue = expectedKey; cache .Setup(x => x.TryGetValue(It.IsAny <object>(), out expectedValue)) .Returns(true); cache .Setup(m => m.CreateEntry(It.IsAny <object>())) .Returns(entry.Object); DeploymentRepository = new DeploymentRepository(context); TripRepository = new TripRepository(context); CollisionRepository = new CollisionRepository(context); ComplaintRepository = new ComplaintRepository(context); CalendarRepository = new CalendarRepository(context, cache.Object); CompanyRepository = new CompanyRepository(context, cache.Object); NeighborhoodRepository = new NeighborhoodRepository(context, cache.Object); PatternAreaRepository = new PatternAreaRepository(context, cache.Object); PaymentTypeRepository = new PaymentTypeRepository(context, cache.Object); PlacementReasonRepository = new PlacementReasonRepository(context, cache.Object); RemovalReasonRepository = new RemovalReasonRepository(context, cache.Object); StatusRepository = new StatusRepository(context, cache.Object); VehicleRepository = new VehicleRepository(context, cache.Object); VehicleTypeRepository = new VehicleTypeRepository(context, cache.Object); Context = context; }
public ComplaintControllerTests(ControllerFixture fixture) { Context = fixture.Context; ComplaintRepository = fixture.ComplaintRepository; CalendarRepository = fixture.CalendarRepository; CompanyRepository = fixture.CompanyRepository; VehicleRepository = fixture.VehicleRepository; VehicleTypeRepository = fixture.VehicleTypeRepository; StatusRepository = fixture.StatusRepository; TripRepository = fixture.TripRepository; Controller = new ComplaintController( new Mock <ILogger <ComplaintController> >().Object, ComplaintRepository, CalendarRepository, CompanyRepository, VehicleRepository ); }
public PlacementReasonRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public CollisionRepository(ScootertownDbContext context) : base(context) { }
static async Task Main(string[] args) { var pathToContentRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var host = new HostBuilder() /* set cwd to the path we are executing in since * running 'dotnet run' would otherwise * set cwd to the folder it is executing from * and the json files we need are being copied to the output directory */ .UseContentRoot(pathToContentRoot) .ConfigureHostConfiguration((builder) => { builder.AddJsonFile("appsettings.json"); }) .ConfigureServices((context, services) => { // AutoMapper setup using profiles. Mapper.Initialize(cfg => { cfg.AddProfile <DeploymentProfile>(); cfg.AddProfile <TripProfile>(); cfg.AddProfile <CollisionProfile>(); cfg.AddProfile <ComplaintProfile>(); cfg.AddProfile <NeighborhoodProfile>(); cfg.AddProfile <PatternAreaProfile>(); cfg.AddProfile <StreetSegmentProfile>(); cfg.AddProfile <BicyclePathProfile>(); cfg.AddProfile <GeoJsonProfile>(); }); // use a different container with more features than the default .NET Core one var container = new Container(); container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); container.Register <ScootertownDbContext>(() => { var builder = new DbContextOptionsBuilder <ScootertownDbContext>(); builder.UseNpgsql( context.Configuration.GetConnectionString("postgres"), o => o.UseNetTopologySuite() ); var options = builder.Options; var dbContext = new ScootertownDbContext( options, new VehicleStoreOptions()); return(dbContext); }, Lifestyle.Scoped); container.Register <AreasOfInterest>(() => { var options = new AreasOfInterest { NeighborhoodsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("NeighborhoodsFile") ), PatternAreasFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("PatternAreasFile") ), StreetSegmentsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("StreetSegmentsFile") ), BicyclePathsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("BicyclePathsFile") ) }; return(options); }, Lifestyle.Scoped); container.Register <APIOptions>(() => { var options = new APIOptions { BaseAddress = context.Configuration.GetValue <string>("BaseAddress") }; return(options); }, Lifestyle.Scoped); // add generic services for repositories for any geojson we'll read in container.Register <INeighborhoodRepository, NeighborhoodRepository>(Lifestyle.Scoped); container.Register <IPatternAreaRepository, PatternAreaRepository>(Lifestyle.Scoped); container.Register <IStreetSegmentRepository, StreetSegmentRepository>(Lifestyle.Scoped); container.Register <IStreetSegmentGroupRepository, StreetSegmentGroupRepository>(Lifestyle.Scoped); container.Register <IBicyclePathRepository, BicyclePathRepository>(Lifestyle.Scoped); container.Register <IBicyclePathGroupRepository, BicyclePathGroupRepository>(Lifestyle.Scoped); container.Register <ITripService, TripService>(Lifestyle.Scoped); container.Register <IDeploymentService, DeploymentService>(Lifestyle.Scoped); container.Register <ICollisionService, CollisionService>(Lifestyle.Scoped); container.Register <IComplaintService, ComplaintService>(Lifestyle.Scoped); container.Register <INeighborhoodService, NeighborhoodService>(Lifestyle.Scoped); container.Register <IPatternAreaService, PatternAreaService>(Lifestyle.Scoped); container.Register <IStreetSegmentService, StreetSegmentService>(Lifestyle.Scoped); container.Register <IBicyclePathService, BicyclePathService>(Lifestyle.Scoped); container.Register(ConfigureLogger, Lifestyle.Singleton); container.Register(typeof(ILogger <>), typeof(LoggingAdapter <>), Lifestyle.Scoped); container.Register <IMemoryCache>(() => { return(new MemoryCache(new MemoryCacheOptions())); }, Lifestyle.Singleton); container.Verify(); // use the default DI to manage our new container services.AddSingleton(container); services.AddSingleton <ILoggerFactory, LoggerFactory>(); // tell the DI container to start the application services.AddSingleton <IHostedService, Host>(); }) .ConfigureLogging((context, logging) => { logging.AddConfiguration(context.Configuration.GetSection("Logging")); logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); logging.AddNLog(); NLog.LogManager.LoadConfiguration("nlog.config"); }) .ConfigureAppConfiguration((context, builder) => { }); await host.RunConsoleAsync(); }
public VehicleRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public PatternAreaRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public StatusRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public RemovalReasonRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public StreetSegmentGroupRepository(ScootertownDbContext context) : base(context) { }
public BicyclePathRepository(ScootertownDbContext context) : base(context) { }
public NeighborhoodRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public DimensionRepositoryBase(ScootertownDbContext context, IMemoryCache cache) : base(context) { Cache = cache; }
public DeploymentRepository(ScootertownDbContext context) : base(context) { }
public ComplaintRepository(ScootertownDbContext context) : base(context) { }
public CalendarRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public TripRepository(ScootertownDbContext context) : base(context) { }
public ComplaintTypeRepository(ScootertownDbContext context, IMemoryCache cache) : base(context, cache) { }
public BridgeBicyclePathGroupRepository(ScootertownDbContext context) : base(context) { }