/// <summary>
 /// Generate and return an email address.
 /// </summary>
 /// <param name="fixture">The fixture to generate a email for</param>
 /// <returns>The generated email</returns>
 public static string EmailAddress(this AnonymousValueFixture fixture)
 {
     if (_personEmailAddressSource == null)
     {
         _personEmailAddressSource = new PersonEmailAddressSource();
     }
     return(_personEmailAddressSource.Next());
 }
        /// <summary>
        /// Generate and return a unique email address (within the fixture).
        /// </summary>
        /// <param name="fixture">The fixture to generate a unique email for</param>
        /// <returns>The generated unique email</returns>
        public static string UniqueEmailAddress(this AnonymousValueFixture fixture)
        {
            if (_uniquePersonEmailAddressSource == null)
            {
                if (_personEmailAddressSource == null)
                {
                    _personEmailAddressSource = new PersonEmailAddressSource();
                }
                var generator = new SequentialGenerator(0, _personEmailAddressSource.Data.Count, listShouldBeUnique: true);
                _uniquePersonEmailAddressSource = new PersonEmailAddressSource(generator);
            }

            return(_uniquePersonEmailAddressSource.Next());
        }
        public void WhenGettingUniqueEmail_ThenReturnUniqueEmailsAcrossFixtureInstances()
        {
            var source          = new PersonEmailAddressSource();
            var generatedValues = new List <string>();
            var any2            = new AnonymousValueFixture();

            generatedValues.Add(any2.UniqueEmailAddress());
            for (var i = 0; i < source.Data.Count - 1; i++)
            {
                generatedValues.Add(Any.UniqueEmailAddress());
            }

            generatedValues.Distinct().Count()
            .ShouldBe(generatedValues.Count);
        }