Exemple #1
0
        public void ShouldGenerateRandomCodes()
        {
            var length = 6;

            var command = new GenerateCodeCommand();

            var codes = new List <string>
            {
                command.Execute(length),
                command.Execute(length),
                command.Execute(length),
                command.Execute(length),
            };

            Assert.True(codes.Distinct().Count() == codes.Count());
        }
Exemple #2
0
        public void ShouldGenerateValidLengthCode()
        {
            var length  = 6;
            var command = new GenerateCodeCommand();

            var code = command.Execute(length);

            Assert.Equal(length, code.Length);
        }
Exemple #3
0
        public void ShouldGenerateValidAlphanumericCode()
        {
            var length = 6;

            var command = new GenerateCodeCommand();

            var code = command.Execute(length);

            Assert.True(code.All(x => char.IsLetterOrDigit(x)));
        }
Exemple #4
0
        public void ShouldGenerateInvalidLengthCode()
        {
            var length  = 8;
            var command = new GenerateCodeCommand();

            var code = command.Execute(length);

            var validator = new CodeValidator();

            Assert.False(validator.Execute(code));
        }