Exemplo n.º 1
0
    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 SignInHttpResult(principal);

        // Act
        await result.ExecuteAsync(httpContext);

        // Assert
        auth.Verify();
    }
Exemplo n.º 2
0
    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 SignInHttpResult(principal, "Scheme1", authProperties);

        // Act
        await result.ExecuteAsync(httpContext);

        // Assert
        auth.Verify();
    }