Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Http/Http.Results/test/ChallengeResultTest.cs')
-rw-r--r--src/Http/Http.Results/test/ChallengeResultTest.cs93
1 files changed, 46 insertions, 47 deletions
diff --git a/src/Http/Http.Results/test/ChallengeResultTest.cs b/src/Http/Http.Results/test/ChallengeResultTest.cs
index 672d3b34ae..3bed9c0378 100644
--- a/src/Http/Http.Results/test/ChallengeResultTest.cs
+++ b/src/Http/Http.Results/test/ChallengeResultTest.cs
@@ -9,54 +9,53 @@ using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Xunit;
-namespace Microsoft.AspNetCore.Http.Result
+namespace Microsoft.AspNetCore.Http.Result;
+
+public class ChallengeResultTest
{
- public class ChallengeResultTest
+ [Fact]
+ public async Task ChallengeResult_ExecuteAsync()
+ {
+ // Arrange
+ var result = new ChallengeResult("", null);
+ var auth = new Mock<IAuthenticationService>();
+ var httpContext = GetHttpContext(auth);
+
+ // Act
+ await result.ExecuteAsync(httpContext);
+
+ // Assert
+ auth.Verify(c => c.ChallengeAsync(httpContext, "", null), Times.Exactly(1));
+ }
+
+ [Fact]
+ public async Task ChallengeResult_ExecuteAsync_NoSchemes()
+ {
+ // Arrange
+ var result = new ChallengeResult(new string[] { }, null);
+ var auth = new Mock<IAuthenticationService>();
+ var httpContext = GetHttpContext(auth);
+
+ // Act
+ await result.ExecuteAsync(httpContext);
+
+ // Assert
+ auth.Verify(c => c.ChallengeAsync(httpContext, null, null), Times.Exactly(1));
+ }
+
+ private static DefaultHttpContext GetHttpContext(Mock<IAuthenticationService> auth)
+ {
+ var httpContext = new DefaultHttpContext();
+ httpContext.RequestServices = CreateServices()
+ .AddSingleton(auth.Object)
+ .BuildServiceProvider();
+ return httpContext;
+ }
+
+ private static IServiceCollection CreateServices()
{
- [Fact]
- public async Task ChallengeResult_ExecuteAsync()
- {
- // Arrange
- var result = new ChallengeResult("", null);
- var auth = new Mock<IAuthenticationService>();
- var httpContext = GetHttpContext(auth);
-
- // Act
- await result.ExecuteAsync(httpContext);
-
- // Assert
- auth.Verify(c => c.ChallengeAsync(httpContext, "", null), Times.Exactly(1));
- }
-
- [Fact]
- public async Task ChallengeResult_ExecuteAsync_NoSchemes()
- {
- // Arrange
- var result = new ChallengeResult(new string[] { }, null);
- var auth = new Mock<IAuthenticationService>();
- var httpContext = GetHttpContext(auth);
-
- // Act
- await result.ExecuteAsync(httpContext);
-
- // Assert
- auth.Verify(c => c.ChallengeAsync(httpContext, null, null), Times.Exactly(1));
- }
-
- private static DefaultHttpContext GetHttpContext(Mock<IAuthenticationService> auth)
- {
- var httpContext = new DefaultHttpContext();
- httpContext.RequestServices = CreateServices()
- .AddSingleton(auth.Object)
- .BuildServiceProvider();
- return httpContext;
- }
-
- private static IServiceCollection CreateServices()
- {
- var services = new ServiceCollection();
- services.AddSingleton(typeof(ILogger<>), typeof(NullLogger<>));
- return services;
- }
+ var services = new ServiceCollection();
+ services.AddSingleton(typeof(ILogger<>), typeof(NullLogger<>));
+ return services;
}
}