private static IEnumerable<BinaryAttachment> GetDistinctInstances()
        {
            var nameGenerator = new RegexLite(@"[A-Za-z0-9]{5,30}");
            var random = new Random();

            for (int i = 0; i < 10000; i++)
                foreach (var mimeType in MimeTypes.All)
                {
                    var bytes = new byte[random.Next(0, 1000)];
                    random.NextBytes(bytes);
                    yield return new BinaryAttachment(nameGenerator.GetRandomString(random), mimeType, bytes);
                }
        }
Esempio n. 2
0
        public void Construct_with_pattern(string input, string expected)
        {
            var pattern = new RegexLite(input);
            var random = new Random();

            Assert.Multiple(() =>
            {
                for (int i = 0; i < 100; i++)
                {
                    string actual = pattern.GetRandomString(random);
                    TestLog.WriteLine(actual);
                    Assert.FullMatch(actual, expected);
                }
            });
        }
        /// <inheritdoc/>
        public override IEnumerable Run()
        {
            try
            {
                regex = new RegexLite(RegularExpressionPattern);
            }
            catch (ArgumentNullException exception)
            {
                throw new GenerationException("The specified regular expression cannot be null.", exception);
            }
            catch (RegexLiteException exception)
            {
                throw new GenerationException(String.Format("The specified regular expression cannot be parsed ({0}).", exception.Message), exception);
            }

            return base.Run();
        }