Ejemplo n.º 1
0
        public async Task CreateSimpleHttpServer_RoutingWithHttpAttributes_FilterExceptionsWithDependencies()
        {
            var httpServer = new OwinHttpServer(new UriBuilder("http://localhost:5000/"));

            var container = new SimpleInjector.Container();

            RegisterVBTraceSource(ref container);

            httpServer.AddDependencyResolver(() => new SimpleInjectorWebApiDependencyResolver(container))
            .SetHttpRouteAttributes()
            .AddFilter((filterCollection, serviceResolver) =>
            {
                IVBTraceSource traceSource = serviceResolver.GetService(typeof(IVBTraceSource)) as IVBTraceSource;
                filterCollection.Add(new PlatformExceptionFilter(traceSource));
            });

            HttpClient client = CreateHttpClient(CreateTestServer(httpServer));

            client.BaseAddress = new Uri("http://localhost");

            var result = await client.GetAsync($"/Device/state/{1}?active=false");

            Assert.Equal(HttpStatusCode.Conflict, result.StatusCode);
        }
Ejemplo n.º 2
0
 public PlatformExceptionFilter(IVBTraceSource traceSource)
 {
     this.traceSource = traceSource;
 }