コード例 #1
0
        public void GenerateReturnsRandomValuesForBooleanTypeTest()
        {
            var target = new BooleanValueGenerator();

            var trueFound = false;
            var falseFound = false;

            for (var index = 0; index < 1000; index++)
            {
                var actual = (bool) target.Generate(typeof (bool), null, null);

                if (actual)
                {
                    trueFound = true;
                }
                else
                {
                    falseFound = true;
                }

                if (trueFound && falseFound)
                {
                    break;
                }
            }

            trueFound.Should().BeTrue();
            falseFound.Should().BeTrue();
        }
コード例 #2
0
        public void GenerateReturnsRandomValuesForBooleanType()
        {
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var sut = new BooleanValueGenerator();

            var trueFound  = false;
            var falseFound = false;

            for (var index = 0; index < 1000; index++)
            {
                var actual = (bool)sut.Generate(executeStrategy, typeof(bool)) !;

                if (actual)
                {
                    trueFound = true;
                }
                else
                {
                    falseFound = true;
                }

                if (trueFound && falseFound)
                {
                    break;
                }
            }

            trueFound.Should().BeTrue();
            falseFound.Should().BeTrue();
        }
コード例 #3
0
        public void GenerateReturnsValueForBooleanTypeTest()
        {
            var target = new BooleanValueGenerator();

            var actual = target.Generate(typeof (bool), null, null);

            actual.Should().BeOfType<bool>();
        }
コード例 #4
0
        public void IsMatchValidatesSupportedTypesTest(Type type, bool expected)
        {
            var buildChain = Substitute.For <IBuildChain>();

            var sut = new BooleanValueGenerator();

            var actual = sut.IsMatch(buildChain, type);

            actual.Should().Be(expected);
        }
コード例 #5
0
        public void GenerateReturnsValueForNullableBooleanTypeTest()
        {
            var target = new BooleanValueGenerator();

            var actual = target.Generate(typeof (bool?), null, null);

            if (actual != null)
            {
                var converted = actual as bool?;

                converted.Should().HaveValue();
            }
        }
コード例 #6
0
        public void IsSupportedThrowsExceptionWithNullTypeTest()
        {
            var target = new BooleanValueGenerator();

            Action action = () => target.IsSupported(null, null, null);

            action.ShouldThrow<ArgumentNullException>();
        }
コード例 #7
0
        public void IsSupportedReturnsTrueForNullableBooleanTypeTest()
        {
            var target = new BooleanValueGenerator();

            var actual = target.IsSupported(typeof (bool?), null, null);

            actual.Should().BeTrue();
        }
コード例 #8
0
        public void IsSupportedReturnsFalseForUnsupportedTypeTest()
        {
            var target = new BooleanValueGenerator();

            var actual = target.IsSupported(typeof (string), null, null);

            actual.Should().BeFalse();
        }