Example #1
0
    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 SignOutResult("", null);

        // Act
        await result.ExecuteAsync(httpContext);

        // Assert
        auth.Verify();
    }
Example #2
0
    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 SignOutResult(new[] { "Scheme1", "Scheme2" }, authProperties);

        // Act
        await result.ExecuteAsync(httpContext);

        // Assert
        auth.Verify();
    }