Beispiel #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment environment, ILogger <DefaultStartup> logger,
                              IApplicationLifetime appLifetime)
        {
            logger.LogInformation("Starting service with environment: {0}", environment.EnvironmentName);

            IocContainer.Set(app.ApplicationServices);

            app.UseMiddleware <EnableRewindMiddleware>();
            app.UseMiddleware <RequestResponseLoggingMiddleware>();
            app.UseMiddleware <RewriteContentTypeMiddleware>();

            appLifetime.ApplicationStopped.Register(() => ApplicationStopped(logger));
            appLifetime.ApplicationStarted.Register(() =>
            {
                ReadyController.ApplicationIsReady();
                _startupStopwatch.Stop();
                logger.LogInformation("Application started in {0} ms", _startupStopwatch.ElapsedMilliseconds);
            });

            app.UseSwagger();
            app.UseFeatures();
            OnConfigureBeforeMvc(app);
            app.UseMvc(OnConfigureRoutes);
            OnConfigureAfterMvc(app);

            app.StartEventProcessors();
            InitService.InitServices(app.ApplicationServices);
        }
Beispiel #2
0
        public void Test_controller_post()
        {
            var readyController = new ReadyController {
                ControllerContext = new ControllerContext {
                    HttpContext = new DefaultHttpContext()
                }
            };
            var body = "{}";

            readyController.Post(body);
            Assert.AreEqual(200, readyController.HttpContext.Response.StatusCode);
        }
Beispiel #3
0
        public void Test_controller_get()
        {
            var readyController = new ReadyController {
                ControllerContext = new ControllerContext {
                    HttpContext = new DefaultHttpContext()
                }
            };
            var response = readyController.Get();

            Assert.AreEqual("200 OK", response);
            Assert.AreEqual(200, readyController.HttpContext.Response.StatusCode);
        }