Пример #1
0
    public async Task ExecuteResultAsync_InvokesSignOutAsyncOnAllConfiguredSchemes()
    {
        // Arrange
        var authProperties = new AuthenticationProperties();
        var httpContext    = new Mock <HttpContext>();
        var auth           = new Mock <IAuthenticationService>();

        auth
        .Setup(c => c.SignOutAsync(httpContext.Object, "Scheme1", authProperties))
        .Returns(Task.CompletedTask)
        .Verifiable();
        auth
        .Setup(c => c.SignOutAsync(httpContext.Object, "Scheme2", authProperties))
        .Returns(Task.CompletedTask)
        .Verifiable();
        httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object));
        var result    = new SignOutResult(new[] { "Scheme1", "Scheme2" }, authProperties);
        var routeData = new RouteData();

        var actionContext = new ActionContext(
            httpContext.Object,
            routeData,
            new ActionDescriptor());

        // Act
        await result.ExecuteResultAsync(actionContext);

        // Assert
        auth.Verify();
    }
Пример #2
0
    public async Task ExecuteResultAsync_InvokesSignOutAsyncOnAuthenticationManager()
    {
        // Arrange
        var httpContext = new Mock <HttpContext>();
        var auth        = new Mock <IAuthenticationService>();

        auth
        .Setup(c => c.SignOutAsync(httpContext.Object, "", null))
        .Returns(Task.CompletedTask)
        .Verifiable();
        httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object));
        var result    = new SignOutResult("", null);
        var routeData = new RouteData();

        var actionContext = new ActionContext(
            httpContext.Object,
            routeData,
            new ActionDescriptor());

        // Act
        await result.ExecuteResultAsync(actionContext);

        // Assert
        auth.Verify();
    }