Example #1
0
        public Route_Controller_Should()
        {
            var configuration = Options.Create(new TravelServiceOptions
            {
                RouterDBPath     = @"D:\OSM",
                RouterDBFileName = "file.routerdb"
            });

            _osmRouter = new OsmRouter(configuration);

            _tourRepositoryMock     = new Mock <ITourRepository>();
            _arrivalTimeServiceMock = new Mock <IArrivalTimeService>();
            _mappingService         = new MappingService();
        }
Example #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IConfiguration configuration, IOsmRouter osmRouter, RoutingAssistantDbContext ctx)
        {
            ctx.Database.EnsureCreated();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                // Enable middleware to serve generated Swagger as a JSON endpoint.
                app.UseSwagger();

                // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
                // specifying the Swagger JSON endpoint.
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                });
            }
            else
            {
                var isApiKeyConfigured = !string.IsNullOrEmpty(configuration.GetValue <string>(Constants.ApiKey));
                if (!isApiKeyConfigured)
                {
                    throw new Exception($"You need to set Environment Variable {Constants.ApiKey}");
                }
                app.UseMiddleware <ApiKeyMiddleware>();
            }
            app.UseMiddleware <ErrorHandlingMiddleware>();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #3
0
 public TravelService(IOsmRouter osmRouter)
 {
     _osmRouter = osmRouter;
 }