Exemplo n.º 1
0
        public void VerifyPassword_CustomValidator_TrueIfPasswordValidElseFalse()
        {
            var repository = new Mock <IRepository>();
            var service    = new PasswordCheckerService(repository.Object, new CustomValidator());

            Assert.That(service.VerifyPassword("123abc").Item1, Is.EqualTo(true));
            Assert.That(service.VerifyPassword("1234567").Item1, Is.EqualTo(false));
        }
        public void IncorrectLegnthTest()
        {
            string password = "******";

            var actual = _passwordCheckService.VerifyPassword
                             (new TextFileRepository(_filePath), _conditions, password);
            var expected = new Tuple <bool, string>(false, $"incorrectLength! length too long");

            Assert.AreEqual(expected, actual);
        }
        public static void Main(string[] args)
        {
            PasswordCheckerService checker = new PasswordCheckerService(new SqlRepository(), new DefaultValidator1(), new DefaultValidator2());

            System.Console.WriteLine(checker.VerifyPassword(string.Empty).Item2);
            System.Console.WriteLine(checker.VerifyPassword("123456").Item2);
            System.Console.WriteLine(checker.VerifyPassword("123afffffffffffffff").Item2);
            System.Console.WriteLine(checker.VerifyPassword("78003560").Item2);
            System.Console.ReadKey();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            IRepository            repository             = new SqlRepository();
            PasswordCheckerService passwordCheckerService = new PasswordCheckerService(repository);
            string result = passwordCheckerService.VerifyPassword("helloIloveU", PasswordCheckerService.DigitCharactersPassWordChecker, PasswordCheckerService.EmptyPassWordChecker).Item2;

            System.Console.WriteLine(result);
            result = passwordCheckerService.VerifyPassword("helloIloveU", PasswordCheckerService.AlphabeticCharactersPassWordChecker, PasswordCheckerService.EmptyPassWordChecker).Item2;
            System.Console.WriteLine(result);
            System.Console.ReadKey();
        }
        static void Main(string[] args)
        {
            PasswordCheckerService checker = new PasswordCheckerService(new SqlRepository());

            System.Console.WriteLine(checker.VerifyPassword(string.Empty).Item2);
            System.Console.WriteLine(checker.VerifyPassword("").Item2);
            System.Console.WriteLine(checker.VerifyPassword("12345").Item2);
            System.Console.WriteLine(checker.VerifyPassword("fdrkjgrdiflgjdiojg").Item2);
            System.Console.WriteLine(checker.VerifyPassword("sjferio").Item2);
            System.Console.ReadKey();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            IRepository            repository = new SqlRepository();
            PasswordCheckerService service    = new PasswordCheckerService(repository);
            List <ICheck>          check      = new List <ICheck>();

            check.Add(new DefaultCheck());
            //string password = "******";
            string password = string.Empty;

            service.VerifyPassword(password, check);
            System.Console.WriteLine(service.VerifyPassword(password, check));
        }
Exemplo n.º 7
0
        public void MainTest()
        {
            PasswordCheckerService checker = new PasswordCheckerService();

            Assert.IsTrue(checker.VerifyPassword("Roman1998", new PasswordDefaultValidator(),
                                                 new SqlRepository()).Item1);
            Console.WriteLine(checker.VerifyPassword("Roman1998", new PasswordDefaultValidator(),
                                                     new SqlRepository()).Item2);
            Assert.IsFalse(checker.VerifyPassword("Roman", new PasswordDefaultValidator(),
                                                  new SqlRepository()).Item1);
            Console.WriteLine(checker.VerifyPassword("Roman", new PasswordDefaultValidator(),
                                                     new DefaultRepository()).Item2);
        }
        public static void TestCheckerService1()
        {
            PasswordCheckerService service = new PasswordCheckerService();
            string password = "******";

            Assert.True(service.VerifyPassword(password, new Predicate <string>[] { (str) => str.Length == 1 }).Item1);
        }
        public static void TestCheckerService()
        {
            PasswordCheckerService service = new PasswordCheckerService();
            string password = "";

            Assert.False(service.VerifyPassword(password, new Predicate <string>[] { service.predicate2 }).Item1);
        }
Exemplo n.º 10
0
        public bool VerifyPassword_DefaultValidator_TrueIfPasswordValidElseFalse(string password)
        {
            var repository = new Mock <IRepository>();
            var service    = new PasswordCheckerService(repository.Object, null);

            return(service.VerifyPassword(password).Item1);
        }
        public bool VerifyPassword_LengthValidator_IsCorrect(string password)
        {
            LengthValidator        validator = new LengthValidator();
            PasswordCheckerService service   = new PasswordCheckerService(new SqlRepository(), validator);

            return(service.VerifyPassword(password).Item1);
        }
Exemplo n.º 12
0
        public Tuple <bool, string> VerifyPasswordTest(string password)
        {
            var repository     = new SqlRepository();
            var verifyPassword = new PasswordCheckerService(repository);

            return(verifyPassword.VerifyPassword(password));
        }
        public void PasswordCheckerServiceTestXmlRepository()
        {
            PasswordCheckerService passwordCheckerXml = new PasswordCheckerService(new XmlRepository());
            var actual = passwordCheckerXml.VerifyPassword("123qw");

            Assert.IsTrue(actual == (false, "123qw length too short"));
        }
Exemplo n.º 14
0
        public void DifferentConditionalTets()
        {
            string password = "******";
            PasswordCheckerService service = new PasswordCheckerService(new SqlRepository());

            Assert.IsFalse(service.VerifyPassword(password));
        }
        public bool VerifyPassword_FailTests(string password, List <IVerifier> verifiers)
        {
            IRepository            repository = new SqlRepository();
            PasswordCheckerService checker    = new PasswordCheckerService(repository);

            return(checker.VerifyPassword(password, verifiers).Item1);
        }
Exemplo n.º 16
0
        static void Main()
        {
            var passwordChecker = new PasswordCheckerService(new SqlRepository());

            System.Console.WriteLine(passwordChecker.VerifyPassword("12485aw", new PasswordEmpty(), new PasswordLessThanSeven()));

            System.Console.ReadKey();
        }
Exemplo n.º 17
0
        public (bool, string) Test_WithCustomCondition(string password, bool result, string stringResult)
        {
            Func <string, bool> func1 = s => s.Any(char.IsPunctuation);
            Func <string, bool> func2 = s => !s.Any(char.IsUpper);
            var passwordChecker       = new PasswordCheckerService(new SqlRepository(), new Func <string, bool>[] { func1, func2 });

            return(passwordChecker.VerifyPassword(password));
        }
Exemplo n.º 18
0
        public void PasswordCheckerServiceCallRepository_CreateMethod(string password)
        {
            var repositoryMock  = new Mock <IRepository>();
            var passwordChecker = new PasswordCheckerService(repositoryMock.Object);

            passwordChecker.VerifyPassword(password, new PasswordEmpty());
            repositoryMock.Verify(repository => repository.Create(It.Is <string>(s => string.Equals(s, password, StringComparison.Ordinal))), Times.Once);
        }
Exemplo n.º 19
0
        public string Test_Verify_Password(string password)
        {
            rules.Add(new ShortPassRule());
            rules.Add(new HasNumberPassRule());
            rules.Add(new HasLetterPassRule());

            return(PasswordCheckerService.VerifyPassword(password, rep, rules).ToString());;
        }
        public bool VerifyPassword_CurrentValidation_ResultOfValidation(string password)
        {
            var repository = new SqlRepository();
            var validator  = new CompositionOfPasswordValidators();

            var checker = new PasswordCheckerService(repository, new[] { validator });

            return(checker.VerifyPassword(password).Item1);
        }
        public bool VerifyPasswordTests(string password)
        {
            var repository             = new SqlRepository();
            var passwordCheckerService = new PasswordCheckerService();

            var result = passwordCheckerService.VerifyPassword(password, repository, Verify);

            return(result.Item1);
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            var repository = new SqlRepository();
            var verifier   = new Verifier
            {
                new PasswordVerification()
            };

            var checkerService = new PasswordCheckerService(repository);

            Console.WriteLine(checkerService.VerifyPassword("", verifier).Item2);
            Console.WriteLine(checkerService.VerifyPassword("abc", verifier).Item2);
            Console.WriteLine(checkerService.VerifyPassword("abcabcabcabcabcabc", verifier).Item2);
            Console.WriteLine(checkerService.VerifyPassword("awdwadawdawd", verifier).Item2);
            Console.WriteLine(checkerService.VerifyPassword("qwerty123", verifier).Item2);

            Console.ReadKey();
        }
Exemplo n.º 23
0
        public void CheckService_True()
        {
            PasswordCheckerService service  = new PasswordCheckerService();
            Tuple <bool, string>   expected = Tuple.Create(true, $"{nameof(password)} is OK. User was created.");

            Tuple <bool, string> actual = service.VerifyPassword(password, s => s.Length <= 5);

            Assert.AreEqual(actual, expected);
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            PasswordCheckerService passwordCheckerService = new PasswordCheckerService();
            var a = passwordCheckerService.VerifyPassword("sadsda");

            System.Console.WriteLine(a);
            var b = passwordCheckerService.VerifyPassword("sadsadd21ds");

            System.Console.WriteLine(b);


            var c = passwordCheckerService.VerifyPassword("sadsda");

            System.Console.WriteLine(c);
            var d = passwordCheckerService.VerifyPassword("sadsadd21ds");

            System.Console.WriteLine(d);
        }
Exemplo n.º 25
0
        public void SqlRepository_IfUserPassIsTrue(string pass, string userType)
        {
            var mock  = new Mock <PasswordCheckerService>();
            var user1 = new PasswordCheckerService();

            user1.VerifyPassword(pass, userType);

            //mock.Verify(sr => sr(It.IsAny<string>()));
        }
Exemplo n.º 26
0
        public void CheckService_False()
        {
            PasswordCheckerService service  = new PasswordCheckerService();
            Tuple <bool, string>   expected = Tuple.Create(false, $"{nameof(password)} is wrong");

            Tuple <bool, string> actual = service.VerifyPassword(password, s => s.Contains("NET"));

            Assert.AreEqual(actual, expected);
        }
Exemplo n.º 27
0
        public void SevingUnsuccessPasswordsInRepoMoqTest(string password)
        {
            Mock <IRepository> mockRepo = new Mock <IRepository>();

            mockRepo.Setup(mr => mr.Create(It.IsAny <string>())).Callback(() => { Assert.Fail(); });
            var verifyPassword = new PasswordCheckerService(mockRepo.Object);

            verifyPassword.VerifyPassword(password);
            Assert.Pass();
        }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            var list = new List <IPasswordValidator>
            {
                new PassValidImpl()
            };
            var checker = new PasswordCheckerService(new SqlRepository());

            checker.VerifyPassword("12345678", list);
        }
Exemplo n.º 29
0
        public void Test1()
        {
            PasswordCheckerService pcService = new PasswordCheckerService(_repository);

            Tuple <bool, string> expTuple = Tuple.Create(true, "Password is Ok. User was created");

            var tuple = pcService.VerifyPassword("Hello777r");

            Assert.AreEqual(expTuple.Item1, tuple);
        }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            IRepository repository = new FakeRepository();

            IPasswordCondition[] conditions =
            {
                new EmptyStringConditions(),
                new InvalidCharacterCondition(),
                new LengthCondition()
            };
            var service = new PasswordCheckerService(repository, conditions);

            var password = "******";

            System.Console.WriteLine(service.VerifyPassword(password));

            password = "";
            System.Console.WriteLine(service.VerifyPassword(password));
            System.Console.ReadKey();
        }