コード例 #1
0
        public void GivenAnyWhenEmailStringThenEmailReturned()
        {
            var email = AnyVal.EmailString();

            email.Should().MatchRegex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Console.WriteLine(email);
        }
コード例 #2
0
        public void GivenAnyWhenNegativeIntegerThenNegativeIntegerReturned()
        {
            var negativeInt = AnyVal.NegativeInt32();

            negativeInt.Should().BeLessOrEqualTo(0);
            Console.WriteLine(negativeInt);
        }
コード例 #3
0
        public void GivenAnyWhenPositiveIntegerThenPositiveIntegerReturned()
        {
            var positiveInt = AnyVal.PositiveInt32();

            positiveInt.Should().BeGreaterOrEqualTo(0);
            Console.WriteLine(positiveInt);
        }
コード例 #4
0
        public void GivenAnyWhenFloatThenFloatReturned()
        {
            var floatVal = AnyVal.Decimal();

            floatVal.Should().BeLessOrEqualTo(100);
            Console.WriteLine(floatVal);
        }
コード例 #5
0
        public void GivenAnyWhenAddressThenAddressReturned()
        {
            var addressReturned = AnyVal.AddressString();

            addressReturned.Should().MatchRegex("^[0-9]{1,4} [a-zA-Z]{8,16} [a-zA-Z]{2}$");
            Console.WriteLine(addressReturned);
        }
コード例 #6
0
        public void GivenAnyAndWhenStringWithSingleQuotesThenStringWithQuotesReturned()
        {
            var alpha = AnyVal.StringWithSingleQuotes();

            alpha.Should().NotBeNullOrEmpty();
            alpha.Should().Contain("\'");
        }
コード例 #7
0
        public void GivenAnyWhenAlphanumericThenAlphanumericReturned()
        {
            var alphaNumericReturned = AnyVal.Alphanumeric();

            alphaNumericReturned.Should().MatchRegex("^[a-zA-Z0-9]*");
            Console.WriteLine(alphaNumericReturned);
        }
コード例 #8
0
        public void GivenAnyWhenPositiveLongThenPositiveLongReturned()
        {
            var positiveLong = AnyVal.PositiveInt64();

            positiveLong.Should().BeGreaterOrEqualTo(0);
            Console.WriteLine(positiveLong);
        }
コード例 #9
0
        public void GivenAnyWhenFloatMaxValThenFloatMaxValReturned()
        {
            const int maxVal   = 500;
            var       floatVal = AnyVal.Decimal(maxVal);

            floatVal.Should().BeLessOrEqualTo(maxVal);
            Console.WriteLine(floatVal);
        }
コード例 #10
0
        public void GivenAnyWhenAlphaThenAlphaReturned()
        {
            var alpha = AnyVal.String();

            alpha.Should().NotBeNullOrEmpty();
            alpha.Should().MatchRegex("^[a-zA-Z]+$");
            Console.WriteLine(alpha);
        }
コード例 #11
0
        public void GivenAnyWhenAlphaLowercaseThenAlphaLowerCaseReturned()
        {
            var alphaLowerCase = AnyVal.StringLowerCase();

            alphaLowerCase.Should().NotBeNullOrEmpty();
            alphaLowerCase.Should().MatchRegex("^[a-z]+$");
            Console.WriteLine(alphaLowerCase);
        }
コード例 #12
0
        public void GivenAnyWhenDateAfterThenDateAfterReturned()
        {
            var dateAfter        = DateTime.Now;
            var dateAfterFromAny = AnyVal.DateTimeAfter(dateAfter);

            dateAfterFromAny.Should().BeAfter(dateAfter);
            Console.WriteLine(dateAfterFromAny);
        }
コード例 #13
0
        public void GivenAnyWhenDateBeforeThenDateBeforeReturned()
        {
            var dateBefore        = DateTime.Now;
            var dateBeforeFromAny = AnyVal.DateTimeBefore(dateBefore);

            dateBeforeFromAny.Should().BeBefore(dateBefore);
            Console.WriteLine(dateBeforeFromAny);
        }
コード例 #14
0
        public void GivenAnyWhenEnumValueOfThenEnumValueReturned()
        {
            var enumValue = AnyVal.OfEnum <TestEnum>();

            ((int)enumValue).Should().BeGreaterOrEqualTo((int)TestEnum.First);
            ((int)enumValue).Should().BeLessOrEqualTo((int)TestEnum.Third);
            Console.WriteLine(enumValue.ToString());
        }
コード例 #15
0
        public void GivenAnyWhenShortParagraphThenParagraphReturned()
        {
            const int maximumLength     = 1;
            var       paragraphReturned = AnyVal.Paragraphs(maximumLength);

            paragraphReturned.Length.Should().Be(maximumLength);
            Console.WriteLine(paragraphReturned);
        }
コード例 #16
0
        public void GivenMinValueAndMaxValueWhenNegativeInt32ThenNegativeValueReturned()
        {
            const int startValue    = -200;
            const int endValue      = -100;
            var       negativeValue = AnyVal.NegativeInt32(startValue, endValue);

            negativeValue.Should().BeGreaterOrEqualTo(startValue);
            negativeValue.Should().BeLessOrEqualTo(endValue);
        }
コード例 #17
0
        public void GivenNegativeFirstIntegerAndPositiveSecondIntegerWhenPositiveIntegerThenValueReturned()
        {
            const int startValue    = -100;
            const int endValue      = 100;
            var       positiveRange = AnyVal.PositiveInt32(startValue, endValue);

            positiveRange.Should().Be(endValue);
            Console.WriteLine(positiveRange);
        }
コード例 #18
0
        public void GivenAnyWhenNegativeIntegerMaxThenNegativeIntegerReturned()
        {
            const int minValue    = -50;
            var       negativeInt = AnyVal.NegativeInt32(minValue);

            negativeInt.Should().BeLessOrEqualTo(0);
            negativeInt.Should().BeGreaterOrEqualTo(minValue);
            Console.WriteLine(negativeInt);
        }
コード例 #19
0
 public void GivenAnyWhenEnumValueOfExceptFirstThenEnumValueReturned()
 {
     for (var tries = 0; tries < 20; tries++)
     {
         var enumValue = AnyVal.OfEnumExceptFirst <TestEnum>();
         enumValue.Should().NotBe(TestEnum.First);
         Console.WriteLine(enumValue.ToString());
     }
 }
コード例 #20
0
        public void GivenAnyWhenPositiveIntegerMaxThenPositiveIntegerReturned()
        {
            const int maxValue    = 50;
            var       positiveInt = AnyVal.PositiveInt32(maxValue);

            positiveInt.Should().BeLessOrEqualTo(maxValue);
            positiveInt.Should().BeGreaterOrEqualTo(0);
            Console.WriteLine(positiveInt);
        }
コード例 #21
0
        public void GivenAnyWhenAlphanumericWithSizeThenAlphanumericReturned()
        {
            var size = AnyVal.PositiveInt32(32);
            var alphaNumericReturned = AnyVal.Alphanumeric(size);

            alphaNumericReturned.Should().MatchRegex("^[a-zA-Z0-9]*");
            alphaNumericReturned.Length.Should().Be(size);
            Console.WriteLine(alphaNumericReturned);
        }
コード例 #22
0
        public void GivenAnyAndSmallSizeWhenStringWithSingleQuotesThenStringWithQuotesReturned()
        {
            const int maxLength = 2;
            var       alpha     = AnyVal.StringWithSingleQuotes(maxLength);

            alpha.Length.Should().Be(maxLength);
            alpha.Should().NotBeNullOrEmpty();
            alpha.Should().Contain("\'");
        }
コード例 #23
0
        public void GivenAnyWhenDateThenDateReturned()
        {
            var dateVal  = AnyVal.DateTime();
            var thisYear = DateTime.Now.Date.Year;

            dateVal.Should().BeAfter(new DateTime(thisYear - 25, 1, 1));
            dateVal.Should().BeBefore(new DateTime(thisYear + 25, 12, 31));
            Console.WriteLine(dateVal);
        }
コード例 #24
0
        public void GivenNegativeFirstIntegerAndNegativeSecondIntegerWhenPositiveIntegerThenValueReturned()
        {
            const int startValue    = -100;
            const int endValue      = -200;
            var       positiveValue = AnyVal.PositiveInt32(startValue, endValue);

            positiveValue.Should().BeGreaterOrEqualTo(Math.Abs(startValue));
            positiveValue.Should().BeLessOrEqualTo(Math.Abs(endValue));
            Console.WriteLine(positiveValue);
        }
コード例 #25
0
        public void GivenAnyWhenNegativeRangeThenPositiveInRangeReturned()
        {
            const int startValue    = 1024;
            const int endValue      = -2048;
            var       positiveRange = AnyVal.PositiveInt32(startValue, endValue);

            positiveRange.Should().BeGreaterOrEqualTo(startValue);
            positiveRange.Should().BeLessOrEqualTo(Math.Abs(endValue));
            Console.WriteLine(positiveRange);
        }
コード例 #26
0
        public void GivenAnyWhenAlphaMaxLenThenAlphaMaxLenReturned()
        {
            const int maxLength = 120;
            var       alpha     = AnyVal.String(maxLength);

            alpha.Length.Should().BeLessOrEqualTo(maxLength);
            alpha.Should().NotBeNullOrEmpty();
            alpha.Should().MatchRegex("^[a-zA-Z]{" + maxLength + "}$");
            Console.WriteLine(alpha);
        }
コード例 #27
0
        public void GivenAnyWhenLongParagraphThenParagraphReturned()
        {
            const int maximumLength     = 500;
            var       paragraphReturned = AnyVal.Paragraphs(maximumLength);

            paragraphReturned.Length.Should().Be(maximumLength);
            paragraphReturned.Should().Contain(" ");
            paragraphReturned.Should().Contain(".\r\n");
            Console.WriteLine(paragraphReturned);
        }