Beispiel #1
0
 private static void Produce(string regex)
 {
     var xeger = new Xeger(regex);
     while (true)
     {
         var sb = new StringBuilder();
         for (int i = 0; i < 1000; ++i)
             sb.AppendLine(xeger.Generate());
         Console.Write(sb.ToString());
     }
 }
        public void Test_Tokenization()
        {
            // see: https://github.com/moodmosaic/Fare
            // and: http://stackoverflow.com/questions/33931059/generate-a-random-string-with-regex
            var xeger = new Xeger(@"((a|t){1,5}\[(t|rt)(,(t|rt)){0,10}\](a|t){1,5}){10,20}");

            for (int i = 0; i < 1000; i++)
            {
                // .... build a string of the form: aa[rt,t,rt]ata[t]aa[rt]aaa[t,t]aaa[rt,rt]ataa...
                var generatedString = xeger.Generate();
                Test_aartt(generatedString);
            }
        }
Beispiel #3
0
 static IEnumerable<string> Xegers(string pattern, System.Random rnd)
 {
     var xeger = new Xeger(pattern, rnd);
     var result = Enumerable.Range(0, 10).Select(x => xeger.Generate());
     result.ToList().ForEach(Console.WriteLine);
     return result;
 }
        private static string GenerateSingleValuedStringTests(BindingDescription bindingDescription)
        {
            var nonMatchTest = "";
            var val = "A string";
            if (!string.IsNullOrEmpty(bindingDescription.StringRegex))
            {
                var xeger = new Xeger(bindingDescription.StringRegex);
                val = xeger.Generate();

                var nonMatch = @"flkj3332@!!!$

            fd333
            ";
                nonMatchTest = string.Format(Templates.NonMatchTest,
                    GetValidCSharpIdentifier(bindingDescription.BoundAttributeType.Name),
                    nonMatch);
            }

            string tests = string.Format(Templates.SingleValuedStringFormatTests,
                GetValidCSharpIdentifier(bindingDescription.BoundAttributeType.Name),
                val,
                nonMatchTest);
            return tests;
        }
        public void It_generates_the_correct_property_and_tests_for_a_binding_thats_not_required()
        {
            // Arrange
            var regExString = "8";
            var bindingDescription = new BindingDescription
            {
                DisplayName = "First Choice for Summary Part I",
                Description = "First Choice for Summary Part II",
                Required = false,
                StringRegex = regExString,
                BoundAttributeType = new AttributeTypeDescription
                {
                    Multivalued = false,
                    DataType = "String",
                    DisplayName = "Second Choice for Summary Part I",
                    Description = "Second Choice for Summary Part II",
                    Name = "PropertyName"
                },
            };
            var xeger = new Xeger(regExString);
            var match = xeger.Generate();
            var nonMatch = @"flkj3332@!!!$

            fd333
            ";
            var expectedTests = string.Format(TestData.BindingNotRequiredTests, match, nonMatch);

            var it = new IdmCodeGenerator(null);

            // Act
            Tuple<string, string> result = it.GenerateAPropertyAndItsTests(bindingDescription);

            // Assert
            ExAssert.AreEqual(TestData.BindingNotRequired, result.Item1);
            ExAssert.AreEqual(expectedTests, result.Item2);
        }