示例#1
0
        public void GeneratorReturnsName()
        {
            var person          = new PersonWithoutGender();
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            buildChain.Push(person);

            var sut = new Wrapper();

            var actual = (string)sut.RunGenerate(typeof(string), "LastName", executeStrategy);

            TestData.LastNames.Any(x => x == actual).Should().BeTrue();
        }
示例#2
0
        public void IsMaleReturnsRandomValueWhenNoGenderPropertyFound()
        {
            var person          = new PersonWithoutGender();
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            buildChain.Push(person);

            var sut = new Wrapper <string>(
                NameExpression.FirstName,
                typeof(string));

            var maleFound    = false;
            var nonMaleFound = false;

            for (var index = 0; index < 1000; index++)
            {
                var actual = sut.GetIsMale(executeStrategy);

                if (actual)
                {
                    maleFound = true;
                }
                else
                {
                    nonMaleFound = true;
                }

                if (maleFound && nonMaleFound)
                {
                    // We have found both random options
                    return;
                }
            }

            throw new AssertionFailedException(
                      $"Did not find both values - Male found {maleFound} - Non-male found {nonMaleFound}");
        }
        public void GeneratorReturnsNameWhenTypeLacksGender()
        {
            var person          = new PersonWithoutGender();
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            buildChain.Push(person);

            var sut = new Wrapper();

            var actual = (string)sut.RunGenerate(typeof(string), "FirstName", executeStrategy);

            if (TestData.MaleNames.Any(x => x == actual))
            {
                // This is a match on a male name so all good
            }
            else
            {
                // Not a male name so it must be a female name
                TestData.FemaleNames.Any(x => x == actual).Should().BeTrue();
            }
        }