public void ExecuteAsync_ThrowsArgumentNullException_WhenHttpContextIsNull() { // Arrange var result = new SignOutHttpResult(); HttpContext httpContext = null; // Act & Assert Assert.ThrowsAsync <ArgumentNullException>("httpContext", () => result.ExecuteAsync(httpContext)); }
public async Task ExecuteAsync_InvokesSignOutAsyncOnAuthenticationManager() { // Arrange var auth = new Mock <IAuthenticationService>(); auth .Setup(c => c.SignOutAsync(It.IsAny <HttpContext>(), "", null)) .Returns(Task.CompletedTask) .Verifiable(); var httpContext = GetHttpContext(auth.Object); var result = new SignOutHttpResult("", null); // Act await result.ExecuteAsync(httpContext); // Assert auth.Verify(); }
public async Task ExecuteAsync_InvokesSignOutAsyncOnAllConfiguredSchemes() { // Arrange var authProperties = new AuthenticationProperties(); var auth = new Mock <IAuthenticationService>(); auth .Setup(c => c.SignOutAsync(It.IsAny <HttpContext>(), "Scheme1", authProperties)) .Returns(Task.CompletedTask) .Verifiable(); auth .Setup(c => c.SignOutAsync(It.IsAny <HttpContext>(), "Scheme2", authProperties)) .Returns(Task.CompletedTask) .Verifiable(); var httpContext = GetHttpContext(auth.Object); var result = new SignOutHttpResult(new[] { "Scheme1", "Scheme2" }, authProperties); // Act await result.ExecuteAsync(httpContext); // Assert auth.Verify(); }