コード例 #1
0
        public void SignUp_ShouldRegUser()
        {
            var context = GetContext();
            var controller = new AccountController(context);

            controller.SignUp(new Models.ViewModels.UserViewModel()
            {
                Name = "ivan",
                Pass = "******"
            });

            var user = context.Users.Auth("ivan", "ivan");
            Assert.IsNotNull(user);
        }
コード例 #2
0
        public void SignUp_ShouldReturnBadRequest_IfNameAlreadyExists()
        {
            var context = GetContext();
            var controller = new AccountController(context);

            context.Users.RegUser("ivan","asd");

            var result = controller.SignUp(new UserViewModel()
            {
                Name = "ivan",
                Pass = "******"
            });

            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
        }
コード例 #3
0
        public void Login_ShouldReturnSession()
        {
            var context = GetContext();
            context.Users.RegUser("ivan", "ivan");
            var controller = new AccountController(context);

            var result = controller.Login(new UserViewModel()
            {
                Name = "ivan",
                Pass = "******"
            })as OkNegotiatedContentResult<SessionViewModel>;

            Assert.IsNotNull(result);
            Assert.IsNotNull(context.Sessions.Find(result.Content.Id));
        }
コード例 #4
0
        public void Login_ShouldReturnBadRequest_IfWrongNameOrPass()
        {
            var context = GetContext();
            var controller = new AccountController(context);

            context.Users.RegUser("ivan", "asd");
            context.Users.RegUser("user", "user");

            var result = controller.Login(new UserViewModel()
            {
                Name = "ivan",
                Pass = "******"
            });

            var result2 = controller.Login(new UserViewModel()
            {
                Name = "userasdf",
                Pass = "******"
            });

            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
            Assert.IsInstanceOfType(result2, typeof(BadRequestErrorMessageResult));
        }