public HttpExceptionsMiddlewareTests() { _nextMock = new Mock <RequestDelegate>(); _optionsMock = TestHelper.CreateHttpExceptionsOptionsMock(true); _actionResultExecutorMock = new Mock <IActionResultExecutor <ObjectResult> >(); _loggerMock = new Mock <ILogger <HttpExceptionsMiddleware> >(); _middleware = new HttpExceptionsMiddleware(_nextMock.Object, _optionsMock.Object, _loggerMock.Object); }
public async Task AddHttpExceptions_Should_AddAllRequiredServices() { var services = new ServiceCollection(); services.AddHttpExceptions(options => options.IncludeExceptionDetails = (_) => true); var servicesProvider = services.BuildServiceProvider(); var middleware = new HttpExceptionsMiddleware( new Mock <RequestDelegate>().Object, servicesProvider.GetRequiredService <IOptions <HttpExceptionsOptions> >(), new Mock <ILogger <HttpExceptionsMiddleware> >().Object); await middleware.Invoke(new DefaultHttpContext()); }
public async Task AddHttpExceptions_Should_AddAllRequiredServices_UsingIMvcCoreBuilder() { var services = new ServiceCollection(); var mvcBuilder = new Mock <IMvcCoreBuilder>(); mvcBuilder.Setup(m => m.Services).Returns(services); mvcBuilder.Object.AddHttpExceptions(options => { }); var servicesProvider = services.BuildServiceProvider(); var middleware = new HttpExceptionsMiddleware( new Mock <RequestDelegate>().Object, servicesProvider.GetRequiredService <IOptions <HttpExceptionsOptions> >(), new Mock <ILogger <HttpExceptionsMiddleware> >().Object); await middleware.Invoke(new DefaultHttpContext()); }