public async Task GetsNamedPolicy(string policyName) { // Arrange var options = new CorsOptions(); var policy = new CorsPolicy(); options.AddPolicy(policyName, policy); var corsOptions = Options.Create(options); var policyProvider = new DefaultCorsPolicyProvider(corsOptions); // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName); // Assert Assert.Same(policy, actualPolicy); }
public async Task GetsNamedPolicy(string policyName) { // Arrange var options = new CorsOptions(); var policy = new CorsPolicy(); options.AddPolicy(policyName, policy); var mockOptions = new Mock<IOptions<CorsOptions>>(); mockOptions .SetupGet(o => o.Options) .Returns(options); var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName); // Assert Assert.Same(policy, actualPolicy); }
public async Task GetsNamedPolicy(string policyName) { // Arrange var options = new CorsOptions(); var policy = new CorsPolicy(); options.AddPolicy(policyName, policy); var corsOptions = new TestCorsOptions { Value = options }; var policyProvider = new DefaultCorsPolicyProvider(corsOptions); // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName); // Assert Assert.Same(policy, actualPolicy); }
public async Task GetsNamedPolicy(string policyName) { // Arrange var options = new CorsOptions(); var policy = new CorsPolicy(); options.AddPolicy(policyName, policy); var mockOptions = new Mock <IOptions <CorsOptions> >(); mockOptions .SetupGet(o => o.Options) .Returns(options); var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName); // Assert Assert.Same(policy, actualPolicy); }