public void WithRequestTimingOptionsThrowsWhenActionNull() { var options = new ServerTimingOptions(); Action invoke = () => options.WithRequestTimingOptions(null); invoke.Should().Throw <ArgumentNullException>(); }
public void TotalMetricNamePropertyValidatesValue(string totalMetricName) { var options = new ServerTimingOptions(); Action validate = () => options.TotalMetricName = totalMetricName; validate.Should().Throw <ArgumentException>() .Which.ParamName.Should().Contain(nameof(ServerTimingOptions.TotalMetricName)); }
public void UseServerTimingWithOptionsThrowsWhenAppNull() { var options = new ServerTimingOptions(); Action use = () => ApplicationBuilderExtensions.UseServerTiming(null, options); use.Should().Throw <ArgumentNullException>() .Which.ParamName.Should().Be("app"); }
public void WithRequestTimingOptionsCapturesAction() { var options = new ServerTimingOptions(); var called = false; options.WithRequestTimingOptions((_, __) => called = true); options.ConfigureRequestTimingOptions(null, null); called.Should().BeTrue(); }
public void ConfigureRequestTimingOptionsInitializedToEmptyAction() { var options = new ServerTimingOptions(); var httpContext = new DefaultHttpContext(); var requestOptions = new RequestTimingOptions(); Action invoke = () => options.ConfigureRequestTimingOptions(httpContext, requestOptions); invoke.Should().NotThrow(); }
public void GlobalSetup() { _serverTimingOptions = new ServerTimingOptions { InvokeCallbackServices = true }; _serverTimingOptions.WithRequestTimingOptions((_, requestOptions) => requestOptions.WriteHeader = true); _middleware = new ServerTimingMiddleware(_ => Task.CompletedTask, _serverTimingOptions, null); _callbacks = Factory.CreateCallbacks(1); }
public void GlobalSetup() { _httpContext = new DefaultHttpContext(); _serverTiming = Factory.CreateServerTiming(); _serverTimingOptions = new ServerTimingOptions(); _requestTimingOptions = new RequestTimingOptions { WriteHeader = true }; _middleware = new ServerTimingMiddleware(_ => Task.CompletedTask, _serverTimingOptions, null); }
public void UseServerTimingInvokesConfigurationAction() { var serviceProvider = new ServiceCollection().BuildServiceProvider(); var app = new ApplicationBuilder(serviceProvider); ServerTimingOptions capturedOptions = null; app.UseServerTiming(options => capturedOptions = options); capturedOptions.Should().NotBeNull(); }
public void InvokeCallbackServicesInitializedToFalse() { var options = new ServerTimingOptions(); options.InvokeCallbackServices.Should().BeFalse(); }
public void ValidateMetricsInitializedToFalse() { var options = new ServerTimingOptions(); options.ValidateMetrics.Should().BeFalse(); }
public void TotalMetricDescriptionInitializedToDefault() { var options = new ServerTimingOptions(); options.TotalMetricDescription.Should().Be(ServerTimingOptions.DefaultTotalDescription); }
public void TotalMetricNameInitializedToDefault() { var options = new ServerTimingOptions(); options.TotalMetricName.Should().Be(ServerTimingOptions.DefaultTotalMetricName); }
public void TimingAllowOriginsInitializedToEmpty() { var options = new ServerTimingOptions(); options.TimingAllowOrigins.Should().BeEmpty(); }
/// <summary> /// Adds a <see cref="ServerTimingMiddleware"/> to application pipeline. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> passed to Configure method.</param> /// <param name="options">The <see cref="ServerTimingOptions"/> to configure the middleware.</param> /// <returns>The original app parameter</returns> public static IApplicationBuilder UseServerTiming(this IApplicationBuilder app, ServerTimingOptions options) { if (app is null) { throw new ArgumentNullException(nameof(app)); } if (options is null) { throw new ArgumentNullException(nameof(options)); } return(app.UseMiddleware <ServerTimingMiddleware>(options)); }