public CodeGenerationConsoleManagerTests(ITestOutputHelper outputHelper)
            : base(outputHelper)
        {
            OutputDirectory = $"{Guid.NewGuid():D}";

            // First is the OutputWriter, second is the ErrorWriter.
            StringBuilders = GetRange(new StringBuilder(), new StringBuilder()).ToArray();
            StringWriters  = StringBuilders.Select(sb => new StringWriter(sb)).ToArray();

            //was using: new TestOutputHelperTextWriter(OutputHelper)
            Manager = new CodeGenerationConsoleManager(StringWriters[0], StringWriters[1]);
        }
Ejemplo n.º 2
0
 public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
 {
     foreach (var row in rows)
     {
         if (ShouldRun(row))
         {
             var sb = StringBuilders.GetObject();
             for (var i = 0; i < _parameters.Count(); i++)
             {
                 sb.Append(row[_parameters[i].Key] ?? _parameters[i].Value.Value);
             }
             row[OutKey] = sb.ToString();
             sb.Clear();
             StringBuilders.PutObject(sb);
         }
         else
         {
             Skip();
         }
         yield return(row);
     }
 }
Ejemplo n.º 3
0
 public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
 {
     foreach (var row in rows)
     {
         if (ShouldRun(row))
         {
             var sb = StringBuilders.GetObject();
             sb.Append('<');
             sb.Append(_tag);
             string content = null;
             foreach (var p in _parameters)
             {
                 var value = (row[p.Key] ?? (p.Value.ValueReferencesField ? row[p.Value.Value] ?? "parameter name conflict!" : p.Value.Value)).ToString();
                 if (_decode)
                 {
                     value = HttpUtility.HtmlDecode(value);
                 }
                 if (p.Value.Name.Equals("content"))
                 {
                     content = value;
                 }
                 else
                 {
                     sb.Append(' ');
                     sb.Append(p.Value.Name);
                     sb.Append("=\"");
                     if (_encode)
                     {
                         XmlEncodeOperation.SanitizeXmlString(HttpUtility.HtmlAttributeEncode(value), ref sb);
                     }
                     else
                     {
                         XmlEncodeOperation.SanitizeXmlString(value, ref sb);
                     }
                     sb.Append('\"');
                 }
             }
             if (content == null)
             {
                 sb.Append(" />");
             }
             else
             {
                 sb.Append('>');
                 if (_encode)
                 {
                     XmlEncodeOperation.SanitizeXmlString(HttpUtility.HtmlEncode(content), ref sb);
                 }
                 else
                 {
                     XmlEncodeOperation.SanitizeXmlString(content, ref sb);
                 }
                 sb.Append("</");
                 sb.Append(_tag);
                 sb.Append(">");
             }
             row[OutKey] = sb.ToString();
             sb.Clear();
             StringBuilders.PutObject(sb);
         }
         else
         {
             Skip();
         }
         yield return(row);
     }
 }