Ejemplo n.º 1
0
        internal static string Handle(GenerateRandomSecretQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            return(RandomSecretGenerator.CreateSecret(query.MinimumLength, query.MaximumLength));
        }
Ejemplo n.º 2
0
            public void SetsLengthProperties()
            {
                const int length = 57;

                var command = new GenerateRandomSecretQuery(length);

                command.MinimumLength.ShouldEqual(length);
                command.MaximumLength.ShouldEqual(length);
            }
            public void GeneratesRandomSecret_OfExactLength()
            {
                const int length = 12;
                var       query  = new GenerateRandomSecretQuery(length);

                var result = GenerateRandomSecretHandler.Handle(query);

                result.ShouldNotBeNull();
                result.Length.ShouldEqual(length);
            }
Ejemplo n.º 4
0
            public void SetsLengthProperties()
            {
                const int minLength = 41;
                const int maxLength = 112;

                var command = new GenerateRandomSecretQuery(minLength, maxLength);

                command.MinimumLength.ShouldEqual(minLength);
                command.MaximumLength.ShouldEqual(maxLength);
            }
            public void GeneratesRandomSecret_OfVariableLength()
            {
                const int minLength = 44;
                const int maxLength = 792;
                var       query     = new GenerateRandomSecretQuery(minLength, maxLength);

                var result = GenerateRandomSecretHandler.Handle(query);

                result.ShouldNotBeNull();
                result.Length.ShouldBeInRange(minLength, maxLength);
            }
Ejemplo n.º 6
0
            public void ThrowsArgumentException_WhenArg_IsLessThanOne()
            {
                ArgumentException exception = null;

                try
                {
                    var obj = new GenerateRandomSecretQuery(0);
                    obj.ShouldBeNull();
                }
                catch (ArgumentException ex)
                {
                    exception = ex;
                }

                exception.ShouldNotBeNull();
                // ReSharper disable PossibleNullReferenceException
                exception.ParamName.ShouldEqual("minimumLength");
                // ReSharper restore PossibleNullReferenceException
            }