/// <summary>
        /// Method to test registering an invalid user with empty strings.
        /// </summary>
        public void CreateUserIncomplete_Login_ReturnsOutOfRange()
        {
            WeSketchSecurity Sec = new WeSketchSecurity();
            var ex = Assert.Catch <ArgumentOutOfRangeException>(() => Sec.CreateUser("", "", ""));

            StringAssert.Contains("System.ArgumentOutOfRangeException", ex.Message);
        }
        public void CreateExistingUser_CreateUser_ReturnsAlreadyExistsError()
        {
            WeSketchSecurity Sec = new WeSketchSecurity();
            var ex = Assert.Catch <Exception>(() => Sec.CreateUser("testerExists", "TestPasswordExists", "*****@*****.**"));

            StringAssert.Contains("already exists.", ex.Message);
        }
        public void ValidLogin_Login_ReturnsUser()
        {
            WeSketchSecurity Sec = new WeSketchSecurity();
            User             usr = Sec.Login("testerSec", "TestPasswordSec");

            Assert.IsNotNull(usr);
        }
        public void CreateValidUser_CreateUser_ReturnsUser()
        {
            WeSketchSecurity Sec = new WeSketchSecurity();
            User             usr = Sec.CreateUser("testerSec", "TestPasswordSec", "*****@*****.**");

            Assert.IsNotNull(usr);
        }
        public void IsInvalidLogin_Login_ReturnsError(string username, string password)
        {
            WeSketchSecurity Sec = new WeSketchSecurity();
            var ex = Assert.Catch <Exception>(() => Sec.Login(username, password));

            StringAssert.Contains("Invalid credentials", ex.Message);
        }
Beispiel #6
0
        public string CreateUser(string user, string password, string email)
        {
            var result = new Result();

            try
            {
                WeSketchSecurity security = new WeSketchSecurity();
                User             newUser  = security.CreateUser(user, password, email);
                WeSketchSharedDataModels.User newUserModel = new WeSketchSharedDataModels.User()
                {
                    UserID   = newUser.UserID,
                    UserName = newUser.UserName,
                    Board    = new Board()
                    {
                        BoardID = newUser.UserBoard.BoardID,
                        Owner   = newUser.UserBoard.BoardOwner
                    }
                };

                result.ResultJSON = JsonConvert.SerializeObject(newUserModel);
            }
            catch (Exception e)
            {
                result.Error        = true;
                result.ErrorMessage = e.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }