diff options
author | Pranav K <prkrishn@hotmail.com> | 2021-11-06 03:52:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-06 03:52:08 +0300 |
commit | a450cb69b5e4549f5515cdb057a68771f56cefd7 (patch) | |
tree | b31cc4cd3257b8aeec14a5481121dac6964195a6 /src/Http/Http.Results/test/SignInResultTest.cs | |
parent | b9fcd82fe9d0883e9828864a8e8b2231f469254f (diff) |
Use file scoped namespaces (#38076)
* Use file scoped namespaces
Diffstat (limited to 'src/Http/Http.Results/test/SignInResultTest.cs')
-rw-r--r-- | src/Http/Http.Results/test/SignInResultTest.cs | 135 |
1 files changed, 67 insertions, 68 deletions
diff --git a/src/Http/Http.Results/test/SignInResultTest.cs b/src/Http/Http.Results/test/SignInResultTest.cs index 2de4d09df7..ba80cce51a 100644 --- a/src/Http/Http.Results/test/SignInResultTest.cs +++ b/src/Http/Http.Results/test/SignInResultTest.cs @@ -10,86 +10,85 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using Xunit; -namespace Microsoft.AspNetCore.Http.Result +namespace Microsoft.AspNetCore.Http.Result; + +public class SignInResultTest { - public class SignInResultTest + [Fact] + public async Task ExecuteAsync_InvokesSignInAsyncOnAuthenticationManager() { - [Fact] - public async Task ExecuteAsync_InvokesSignInAsyncOnAuthenticationManager() - { - // Arrange - var principal = new ClaimsPrincipal(); - var auth = new Mock<IAuthenticationService>(); - auth - .Setup(c => c.SignInAsync(It.IsAny<HttpContext>(), "", principal, null)) - .Returns(Task.CompletedTask) - .Verifiable(); + // Arrange + var principal = new ClaimsPrincipal(); + var auth = new Mock<IAuthenticationService>(); + auth + .Setup(c => c.SignInAsync(It.IsAny<HttpContext>(), "", principal, null)) + .Returns(Task.CompletedTask) + .Verifiable(); - var httpContext = GetHttpContext(auth.Object); - var result = new SignInResult("", principal, null); + var httpContext = GetHttpContext(auth.Object); + var result = new SignInResult("", principal, null); - // Act - await result.ExecuteAsync(httpContext); + // Act + await result.ExecuteAsync(httpContext); - // Assert - auth.Verify(); - } + // Assert + auth.Verify(); + } - [Fact] - public async Task ExecuteAsync_InvokesSignInAsyncOnAuthenticationManagerWithDefaultScheme() - { - // Arrange - var principal = new ClaimsPrincipal(); - var auth = new Mock<IAuthenticationService>(); - auth - .Setup(c => c.SignInAsync(It.IsAny<HttpContext>(), null, principal, null)) - .Returns(Task.CompletedTask) - .Verifiable(); - var httpContext = GetHttpContext(auth.Object); - var result = new SignInResult(principal); + [Fact] + public async Task ExecuteAsync_InvokesSignInAsyncOnAuthenticationManagerWithDefaultScheme() + { + // Arrange + var principal = new ClaimsPrincipal(); + var auth = new Mock<IAuthenticationService>(); + auth + .Setup(c => c.SignInAsync(It.IsAny<HttpContext>(), null, principal, null)) + .Returns(Task.CompletedTask) + .Verifiable(); + var httpContext = GetHttpContext(auth.Object); + var result = new SignInResult(principal); - // Act - await result.ExecuteAsync(httpContext); + // Act + await result.ExecuteAsync(httpContext); - // Assert - auth.Verify(); - } + // Assert + auth.Verify(); + } - [Fact] - public async Task ExecuteAsync_InvokesSignInAsyncOnConfiguredScheme() - { - // Arrange - var principal = new ClaimsPrincipal(); - var authProperties = new AuthenticationProperties(); - var auth = new Mock<IAuthenticationService>(); - auth - .Setup(c => c.SignInAsync(It.IsAny<HttpContext>(), "Scheme1", principal, authProperties)) - .Returns(Task.CompletedTask) - .Verifiable(); - var httpContext = GetHttpContext(auth.Object); - var result = new SignInResult("Scheme1", principal, authProperties); + [Fact] + public async Task ExecuteAsync_InvokesSignInAsyncOnConfiguredScheme() + { + // Arrange + var principal = new ClaimsPrincipal(); + var authProperties = new AuthenticationProperties(); + var auth = new Mock<IAuthenticationService>(); + auth + .Setup(c => c.SignInAsync(It.IsAny<HttpContext>(), "Scheme1", principal, authProperties)) + .Returns(Task.CompletedTask) + .Verifiable(); + var httpContext = GetHttpContext(auth.Object); + var result = new SignInResult("Scheme1", principal, authProperties); - // Act - await result.ExecuteAsync(httpContext); + // Act + await result.ExecuteAsync(httpContext); - // Assert - auth.Verify(); - } + // Assert + auth.Verify(); + } - private static DefaultHttpContext GetHttpContext(IAuthenticationService auth) - { - var httpContext = new DefaultHttpContext(); - httpContext.RequestServices = CreateServices() - .AddSingleton(auth) - .BuildServiceProvider(); - return httpContext; - } + private static DefaultHttpContext GetHttpContext(IAuthenticationService auth) + { + var httpContext = new DefaultHttpContext(); + httpContext.RequestServices = CreateServices() + .AddSingleton(auth) + .BuildServiceProvider(); + return httpContext; + } - private static IServiceCollection CreateServices() - { - var services = new ServiceCollection(); - services.AddSingleton(typeof(ILogger<>), typeof(NullLogger<>)); - return services; - } + private static IServiceCollection CreateServices() + { + var services = new ServiceCollection(); + services.AddSingleton(typeof(ILogger<>), typeof(NullLogger<>)); + return services; } } |