public void should_validate_data()
 {
     //arrange
     var validator = new Validator();
     string userName = Guid.NewGuid().ToString();
     string userPassword = Guid.NewGuid().ToString();
     //act
     var res = validator.Validate(userName, userPassword);
     //assert
     Assert.True(res);
 }
        public void should_handle_invalid_data_for_user_name(char symb)
        {
            //arrange
            var validator = new Validator();

            //act
            var ret = validator.Validate(Guid.NewGuid().ToString() + symb, Guid.NewGuid().ToString());

            //assert
            //Assert.AreEqual(false, ret);
            ret.ShouldBeEquivalentTo(false);
        }
        public void should_handle_invalid_user_password(string userPassword)
        {
            //arrange
            var validator = new Validator();

            //act
            var ret = validator.Validate(Guid.NewGuid().ToString(), userPassword);

            //assert
            //Assert.AreEqual(false, ret);
            ret.ShouldBeEquivalentTo(false);
        }
Example #4
0
        public void should_validate_with_valid_userName_userPassword()
        {
            //arrange
            var validator = new Validator();
            string userName = "";
            string userPassword = Guid.NewGuid().ToString();

            bool actual = true;

            if (string.IsNullOrWhiteSpace(userName)
                || string.IsNullOrWhiteSpace(userPassword))
            {
                actual = false;
            }
            else
            {
                //userName shouldn't have this characters
                var invalidSymbols = new char[] { '@', '%', '#' };

                foreach (var s in invalidSymbols)
                {
                    if (userName.Contains(s))
                    {
                        actual = false;
                        break;
                    }
                }
            }

            //act
            var res = validator.Validate(userName, userPassword);

            //assert
            Assert.AreEqual(actual, res);
        }