Example #1
0
 public string CreateInput(string setupText, string testText, string concreteClass)
 {
     var setup = setupText ?? string.Empty;
     var tests = testText ?? string.Empty;
     var inputs = new Dictionary<string, object> {{"setupContents", setup}, {"testContents", tests}, {"concreteClass", concreteClass}};
     return inputs.AsNVelocityTemplate(TemplateEnum.InputWrapper);
 }
Example #2
0
 public string GenerateTestFixture(List<Test> tests, string fileName)
 {
     var stringBuilder = new StringBuilder();
     var count = tests.Count;
     var templateInputs = new Dictionary<string, object>();
     for (var i = 0; i < count; i++)
     {
         stringBuilder.Append(GenerateTest(tests[i], "", [email protected]));
         var typeList = tests[i].TypeList;
         var typeCount = typeList.Count;
         if (tests[i].TypeList != null && typeCount > 0)
         {
             var interfaceText = new StringBuilder();
             for (var j = 0; j < typeCount; j++)
             {
                 interfaceText.Append(_interfaceGenerator.Generate(typeList[j]));
             }
             templateInputs.Add("interfaces", interfaceText.ToString());
         }
         else
         {
             templateInputs.Add("interfaces", string.Empty);
         }
     }
     //testFixture = testFixture.Replace("##fixturename##", tests[0].Title);
     //testFixture = testFixture.Replace("##tests##", stringBuilder.ToString());
     templateInputs.Add("testTitle", tests[0].Title);
     templateInputs.Add("tests", stringBuilder.ToString());
     return templateInputs.AsNVelocityTemplate(TestFixtureTemplate);
 }
        private string TemplateIfStatement(If ifStatement, object nestedIfText, bool isNested, ref StringBuilder builder)
        {
            var constraintText = new StringBuilder();
            var elseConstraintText = new StringBuilder();
            var conditionText = string.Empty;

            conditionText = _booleanGenerator.Generate(ifStatement.TargetList, ref builder);
            constraintText = GenerateConstraints(ifStatement.Then.Constraints, constraintText);

            if (ifStatement.Else != null)
            {
                elseConstraintText = GenerateConstraints(ifStatement.Else.Constraints, elseConstraintText);
            }

            var templateParams = new Dictionary<string, object>
                                     {
                                         {"condition", conditionText},
                                         {"constraints", constraintText.ToString()},
                                         {"nestedIf", nestedIfText},
                                         {"hasNestedIf", nestedIfText != null},
                                         {"isNested", isNested},
                                         {"elseConstraints", elseConstraintText}
                                     };
            return templateParams.AsNVelocityTemplate(TemplateEnum.IfElseStatement);
        }