Exemplo n.º 1
0
 public void Can_Redirect_IfUserHasSessionAlready()
 {
     var ac = new AccountController(formService.Object, memberService.Object, userRepo.Object, openIdService.Object);
     sessionState.SetupGet(k => k[SessionConstants.OpenId]).Returns("blah blah");
     ac.ControllerContext = new ControllerContext(mockhttpContext.Object, new RouteData(), ac);
     var result = ac.LogOn().ReturnsRedirectToRouteResult().RedirectsTo<HomeController>(ctrller => ctrller.Index());
 }
Exemplo n.º 2
0
        public void Can_Redirect_ToHomeIndex_IfUserExists()
        {
            var identifier = Identifier.Parse("http://uniqueId/");

            var mockAuthResponse = new Mock<IAuthenticationResponse>();
            mockAuthResponse.SetupGet(res => res.ClaimedIdentifier).Returns(identifier);
            //mockAuthResponse.SetupGet(res => res.FriendlyIdentifierForDisplay).Returns("FriendlyId");
            mockAuthResponse.SetupGet(res => res.Status).Returns(AuthenticationStatus.Authenticated);

            userRepo.Setup(k => k.FindByOpenId(identifier.ToString())).Returns(new User() { DisplayName = "Test Display Name"});

            openIdService.Setup(k => k.GetResponse()).Returns(mockAuthResponse.Object);

            sessionState.SetupSet(k => { k[SessionConstants.OpenId] = identifier; });
            sessionState.SetupSet(k => { k[SessionConstants.DisplayName] = "Test Display Name"; });

            var ac = new AccountController(formService.Object, memberService.Object, userRepo.Object, openIdService.Object);
            ac.ControllerContext = new ControllerContext(mockhttpContext.Object, new RouteData(), ac);
            var result = ac.LogOn().ReturnsRedirectToRouteResult().RedirectsTo<HomeController>(ctrller=>ctrller.Index());

            sessionState.VerifyAll();
            mockAuthResponse.VerifyAll();
            userRepo.VerifyAll();
            openIdService.VerifyAll();
        }
Exemplo n.º 3
0
 public void Can_Return_OpenIdPartialView_WhenAjax()
 {
     requestObject.SetupGet(x => x.Headers).Returns(
             new System.Net.WebHeaderCollection {
                 {"X-Requested-With", "XMLHttpRequest"}
             });
     var ac = new AccountController(formService.Object, memberService.Object, userRepo.Object, openIdService.Object);
     ac.ControllerContext = new ControllerContext(mockhttpContext.Object, new RouteData(), ac);
     // it returns the default view
     var result = ac.OpenIdPopup()
                    .ReturnsPartialViewResult()
                    .ForView("_OpenIdHtml");
 }
Exemplo n.º 4
0
 public void Can_Return_OpenIdPopupView_When_NotAjax()
 {
     var ac = new AccountController(formService.Object, memberService.Object, userRepo.Object, openIdService.Object);
     ac.ControllerContext = new ControllerContext(mockhttpContext.Object, new RouteData(), ac);
     // it returns the default view
     var result = ac.OpenIdPopup()
                    .ReturnsViewResult()
                    .ForView("");
 }