public async Task ChallengeResult_ExecuteNoSchemes()
        {
            // Arrange
            var result = new ChallengeResult(new string[] { }, null);

            var httpContext = new Mock <HttpContext>();

            httpContext.SetupGet(c => c.RequestServices).Returns(CreateServices().BuildServiceProvider());

            var auth = new Mock <AuthenticationManager>();

            httpContext.Setup(o => o.Authentication).Returns(auth.Object);

            var routeData = new RouteData();

            routeData.Routers.Add(Mock.Of <IRouter>());

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

            // Act
            await result.ExecuteResultAsync(actionContext);

            // Assert
            auth.Verify(c => c.ChallengeAsync((AuthenticationProperties)null), Times.Exactly(1));
        }
Example #2
0
        public async Task ChallengeResult_ExecuteNoSchemes()
        {
            // Arrange
            var result = new ChallengeResult(new string[] { }, null);
            var httpContext = new Mock<HttpContext>();
            var auth = new Mock<AuthenticationManager>();
            httpContext.Setup(o => o.Authentication).Returns(auth.Object);

            var routeData = new RouteData();
            routeData.Routers.Add(Mock.Of<IRouter>());

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

            // Act
            await result.ExecuteResultAsync(actionContext);

            // Assert
            auth.Verify(c => c.ChallengeAsync((AuthenticationProperties)null), Times.Exactly(1));
        }
Example #3
0
        public async Task ChallengeResult_Execute()
        {
            // Arrange
            var result      = new ChallengeResult("", null);
            var httpContext = new Mock <HttpContext>();
            var auth        = new Mock <AuthenticationManager>();

            httpContext.Setup(o => o.Authentication).Returns(auth.Object);

            var routeData = new RouteData();

            routeData.Routers.Add(Mock.Of <IRouter>());

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

            // Act
            await result.ExecuteResultAsync(actionContext);

            // Assert
            auth.Verify(c => c.ChallengeAsync("", null), Times.Exactly(1));
        }
Example #4
0
        public async Task ChallengeResult_Execute()
        {
            // Arrange
            var result = new ChallengeResult("", null);

            var httpContext = new Mock<HttpContext>();
            httpContext.SetupGet(c => c.RequestServices).Returns(CreateServices().BuildServiceProvider());

            var auth = new Mock<AuthenticationManager>();
            httpContext.Setup(o => o.Authentication).Returns(auth.Object);

            var routeData = new RouteData();
            routeData.Routers.Add(Mock.Of<IRouter>());

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

            // Act
            await result.ExecuteResultAsync(actionContext);

            // Assert
            auth.Verify(c => c.ChallengeAsync("", null), Times.Exactly(1));
        }