Example #1
0
 public void Query_Ctor_Exact_SetsBothMinAndMaxLengthProperties_WhenArgumentIsInRange()
 {
     var exactLength = FakeData.Id();
     var query = new RandomSecret(exactLength);
     query.MinLength.ShouldEqual(exactLength);
     query.MaxLength.ShouldEqual(exactLength);
 }
Example #2
0
 public void Query_Ctor_MinMax_SetsMinAndMaxLengthProperties_WhenArgumentsAreInRange()
 {
     var minLength = FakeData.Int(1, int.MaxValue / 2);
     var maxLength = FakeData.Int(minLength, int.MaxValue);
     var query = new RandomSecret(minLength, maxLength);
     query.MinLength.ShouldEqual(minLength);
     query.MaxLength.ShouldEqual(maxLength);
 }
Example #3
0
        public void Handler_ReturnsValue_FromSecretCreator()
        {
            var minLength = FakeData.Int(1, 50);
            var maxLength = FakeData.Int(minLength, 100);
            var secret = FakeData.String();
            while (secret.Length < minLength)
                secret += FakeData.String();
            while (secret.Length > maxLength)
                secret = secret.Substring(0, secret.Length - 2);
            var secretCreator = new Mock<ICreateSecrets>(MockBehavior.Strict);
            secretCreator.Setup(x => x.CreateSecret(minLength, maxLength))
                .Returns(secret);
            var handler = new HandleRandomSecretQuery(secretCreator.Object);
            var query = new RandomSecret(minLength, maxLength);

            string result = handler.Handle(query);

            result.ShouldEqual(secret);
            secretCreator.Verify(x => x.CreateSecret(minLength, maxLength), Times.Once);
        }