public void ResolvePolicy_DefaultKeyLifetime() { IServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddOptions(); RunTestWithRegValues(serviceCollection, new Dictionary<string, object>() { ["DefaultKeyLifetime"] = 1024 // days }); var services = serviceCollection.BuildServiceProvider(); var keyManagementOptions = services.GetService<IOptions<KeyManagementOptions>>(); Assert.Equal(TimeSpan.FromDays(1024), keyManagementOptions.Options.NewKeyLifetime); }
private static HttpContext GetHttpContext() { var httpContext = new DefaultHttpContext(); httpContext.Response.Body = new MemoryStream(); var services = new ServiceCollection(); services.AddOptions(); httpContext.RequestServices = services.BuildServiceProvider(); return httpContext; }