public void PriorityReturnsValueLowerThanEmailValueGenerator()
        {
            var sut   = new AddressValueGenerator();
            var other = new EmailValueGenerator();

            sut.Priority.Should().BeLessThan(other.Priority);
        }
        public void ImplementedByTypeReturnsGeneratorType()
        {
            var generator = new EmailValueGenerator();

            var sut = new BuildCapability(generator);

            sut.ImplementedByType.Should().Be <EmailValueGenerator>();
        }
        public void GenerateReturnsDomainFromTestDataTest()
        {
            var person = new Person();
            var buildChain = new LinkedList<object>();

            buildChain.AddFirst(person);

            var target = new EmailValueGenerator();

            var actual = (string)target.Generate(typeof(string), "email", buildChain);

            var domain = actual.Substring(actual.IndexOf("@") + 1);

            TestData.People.Any(x => x.Domain.ToLowerInvariant() == domain).Should().BeTrue();
        }
        public void GenerateReturnsFirstAndLastNameRelativeToFemaleGenderTest()
        {
            var person = new Person
            {
                Gender = Gender.Female
            };
            var buildChain = new LinkedList<object>();

            buildChain.AddFirst(person);

            var target = new EmailValueGenerator();

            var actual = (string)target.Generate(typeof(string), "email", buildChain);

            var firstName = actual.Substring(0, actual.IndexOf("."));

            TestData.Females.Any(x => x.FirstName.ToLowerInvariant() == firstName).Should().BeTrue();
        }
        public void GenerateReturnsEmailAddressWithNameSpacesRemovedTest()
        {
            var person = new Person
            {
                FirstName = "De Jour",
                LastName = "Mc Cormick"
            };
            var buildChain = new LinkedList<object>();

            buildChain.AddFirst(person);

            var target = new EmailValueGenerator();

            var actual = (string)target.Generate(typeof(string), "email", buildChain);

            var expected = "dejour.mccormick";

            actual.Should().StartWith(expected.ToLowerInvariant());
        }
        public void IsSupportedThrowsExceptionWithNullTypeTest()
        {
            var person = new Person();
            var buildChain = new LinkedList<object>();

            buildChain.AddFirst(person);

            var target = new EmailValueGenerator();

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

            action.ShouldThrow<ArgumentNullException>();
        }
        public void IsSupportedThrowsExceptionWithNullContextTest()
        {
            var target = new EmailValueGenerator();

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

            actual.Should().BeFalse();
        }
        public void IsSupportedTest(Type type, string referenceName, bool expected)
        {
            var person = new Person();
            var buildChain = new LinkedList<object>();

            buildChain.AddFirst(person);

            var target = new EmailValueGenerator();

            var actual = target.IsSupported(type, referenceName, buildChain);

            actual.Should().Be(expected);
        }
        public void HasHigherPriorityThanStringValueGeneratorTest()
        {
            var target = new EmailValueGenerator();
            var other = new StringValueGenerator();

            target.Priority.Should().BeGreaterThan(other.Priority);
        }
        public void GenerateThrowsExceptionWithNullTypeTest()
        {
            var target = new EmailValueGenerator();

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

            action.ShouldThrow<ArgumentNullException>();
        }
        public void GenerateThrowsExceptionWithNullContextTest()
        {
            var target = new EmailValueGenerator();

            Action action = () => target.Generate(typeof(string), "email", null);

            action.ShouldThrow<NotSupportedException>();
        }
        public void GenerateThrowsExceptionWithInvalidParametersTest(Type type, string referenceName)
        {
            var target = new EmailValueGenerator();

            Action action = () => target.Generate(type, referenceName, null);

            action.ShouldThrow<NotSupportedException>();
        }
        public void GenerateReturnsValueWhenContextLacksNameAndGenderPropertiesTest()
        {
            var model = new SlimModel();
            var buildChain = new LinkedList<object>();

            buildChain.AddFirst(model);

            var target = new EmailValueGenerator();

            var actual = (string)target.Generate(typeof(string), "email", buildChain);

            actual.Should().NotBeNullOrWhiteSpace();
        }
        public void GenerateReturnsRandomEmailAddressUsingLastNameOfContextTest()
        {
            var person = new Person
            {
                LastName = Guid.NewGuid().ToString("N")
            };
            var buildChain = new LinkedList<object>();

            buildChain.AddFirst(person);

            var target = new EmailValueGenerator();

            var actual = (string)target.Generate(typeof(string), "email", buildChain);

            var expected = person.LastName;

            actual.Should().Contain(expected.ToLowerInvariant());
        }
        public void GenerateReturnsRandomEmailAddressTest()
        {
            var firstPerson = new Person
            {
                FirstName = "De Jour",
                LastName = "Mc Cormick"
            };
            var firstBuildChain = new LinkedList<object>();

            firstBuildChain.AddFirst(firstPerson);

            var target = new EmailValueGenerator();

            var first = target.Generate(typeof(string), "email", firstBuildChain);

            first.Should().BeOfType<string>();
            first.As<string>().Should().NotBeNullOrWhiteSpace();
            first.As<string>().Should().Contain("@");

            var secondPerson = new Person
            {
                FirstName = "Sam",
                LastName = "Johns"
            };
            var secondBuildChain = new LinkedList<object>();

            secondBuildChain.AddFirst(secondPerson);

            var second = target.Generate(typeof(string), "email", secondBuildChain);

            first.Should().NotBe(second);
        }
        public void HasLowerPriorityThanEmailValueGeneratorTest()
        {
            var target = new AddressValueGenerator();
            var other = new EmailValueGenerator();

            target.Priority.Should().BeLessThan(other.Priority);
        }