public void AccountControllerLogin()
        {
            const bool ISAJAX = true;
            var info = new LoginModel()
            {
                Email = "Admin",
                Password = "******"
            };
            string returnUrl = "returnUrl";

            var factory = new WorkChannelFactoryMock();
            var auth = new FakeAuthenticationService();
            var ctrl = new AccountController(factory, auth);
            FakeControllerSession.SetFakeControllerContext(ctrl, ISAJAX);

            //Pass if everything ok
            var res2 = ctrl.Login(info, returnUrl) as RedirectToRouteResult;
            Assert.IsNotNull(res2);
            Assert.AreEqual(res2.RouteValues["action"], "Index");

            var user = ctrl.Session["User"] as UserDTO;
            Assert.IsNotNull(user);
            Assert.AreEqual(user.Email, "Admin");
            Assert.AreEqual(user.Password, "123");

            //Fault when wrong user
            info.Email = "unknown";
            var res3 = ctrl.Login(info, returnUrl) as ViewResult;
            Assert.IsNotNull(res3);
            Assert.AreEqual(res3.Model, "wrong user");
        }
        public void AccountControllerLogoff()
        {
            const bool ISAJAX = true;

            var factory = new WorkChannelFactoryMock();
            var auth = new FakeAuthenticationService();
            var ctrl = new AccountController(factory, auth);
            FakeControllerSession.SetFakeControllerContext(ctrl, ISAJAX);

            var res2 = ctrl.LogOff() as RedirectToRouteResult;
            Assert.IsNotNull(res2);
            Assert.AreEqual(res2.RouteValues["action"], "Index");
        }
        public void AccountControllerRegister()
        {
            const bool ISAJAX = true;
            var info = new RegisterViewModel()
            {
                UserName = "******",
                Password = "******",
                ConfirmPassword = "******",
                Address = "asd"
            };

            var factory = new WorkChannelFactoryMock();
            var auth = new FakeAuthenticationService();
            var ctrl = new AccountController(factory, auth);
            FakeControllerSession.SetFakeControllerContext(ctrl, ISAJAX);

            var res2 = ctrl.Register(info) as RedirectToRouteResult;
            Assert.IsNotNull(res2);
            Assert.AreEqual(res2.RouteValues["action"], "Index");
            Assert.AreEqual(factory.LastWorkChannel.UsersRegistered.Count, 1);
            Assert.AreEqual(factory.LastWorkChannel.UsersRegistered[0].Email, "Admin");
        }