public void SetUp()
        {
            fakeDB             = new FakeDB();
            ClarityDB.Instance = fakeDB;
            Presto.Persist <User>(x => x.UserName = "******");
            user = Presto.Persist <User>(x => x.UserName = "******");

            fakeFormsAuthentication = new FakeFormsAuthentication();
            service = new AuthenticationService(fakeFormsAuthentication, new FakePasswordHash(), null);
        }
        public void SignInRedirectsToUrlForNonNullReturnUrl()
        {
            FakeUserService         userService = new FakeUserService();
            FakeFormsAuthentication formsAuth   = new FakeFormsAuthentication();

            UserController controller = new UserController(formsAuth, userService);

            ActionResult result = controller.SignIn("test", "test", true, "/test") as ActionResult;

            Assert.IsType <RedirectResult>(result);
            RedirectResult redirectResult = result as RedirectResult;

            Assert.Equal("/test", redirectResult.Url);
        }
        public void SignInSetsCookieForValidUser()
        {
            FakeUserService         userService = new FakeUserService();
            FakeFormsAuthentication formsAuth   = new FakeFormsAuthentication();

            RouteCollection routes = new RouteCollection();

            routes.Add("Posts", new Route("", new MvcRouteHandler()));

            UrlHelper helper = new UrlHelper(new RequestContext(new FakeHttpContext(new Uri("http://oxite.net/"), "~/"), new RouteData()), routes);

            UserController controller = new UserController(formsAuth, userService)
            {
                Url = helper
            };

            controller.SignIn("test", "test", true, null);

            Assert.Equal("test", formsAuth.LastUserName);
            Assert.True(formsAuth.LastPersistCookie);
        }
        public void SignInRedirectsToHomePageForNullReturnUrl()
        {
            FakeUserService         userService = new FakeUserService();
            FakeFormsAuthentication formsAuth   = new FakeFormsAuthentication();

            RouteCollection routes = new RouteCollection();

            routes.Add("Posts", new Route("", new MvcRouteHandler()));

            UrlHelper helper = new UrlHelper(new RequestContext(new FakeHttpContext(new Uri("http://oxite.net/"), "~/"), new RouteData()), routes);

            UserController controller = new UserController(formsAuth, userService)
            {
                Url = helper
            };

            ActionResult result = controller.SignIn("test", "test", true, null) as ActionResult;

            Assert.IsType <RedirectResult>(result);
            RedirectResult redirectResult = result as RedirectResult;

            Assert.Equal("/", redirectResult.Url);
        }
Beispiel #5
0
 public void GivenIHaveNotBeenAuthenticatedYet()
 {
     var formsAuthentication = new FakeFormsAuthentication();
     ScenarioContext.Current.Set(formsAuthentication);
 }
Beispiel #6
0
 public void GivenIAmAuthenticatedAs(string email)
 {
     var formsAuthentication = new FakeFormsAuthentication();
     formsAuthentication.SetAuthenticationToken(email, true);
     ScenarioContext.Current.Set(formsAuthentication);
 }