Example #1
0
        private string BuildScenarioText(string text, string statementType, ScenarioOutputOptions outputOptions)
        {
            var statementOptions = outputOptions.StatementOptions.Single(s => s.Prefix == statementType);

            var firstOccurence = !_displayedPrefixes.Contains(statementOptions.Prefix);
            var sb             = new StringBuilder();

            string prefix;

            if (firstOccurence)
            {
                _displayedPrefixes.Add(statementOptions.Prefix);

                if (statementOptions.InsertLineSpaceBeforeFirstOccurrence)
                {
                    sb.AppendLine(statementOptions.LineSpaceText);
                }

                prefix = statementOptions.Prefix;
            }
            else
            {
                prefix = statementOptions.PrefixAfterFirstOccurence;
            }

            if (outputOptions.PrefixStatementsWithDate)
            {
                sb.Append(DateTime.Now.ToString(outputOptions.PrefixStatementsWithDateTimeFormat)).Append(" ");
            }

            if (statementOptions.IndentWithOtherStatements)
            {
                prefix = firstOccurence
                    ? prefix.PadRight(outputOptions.MaxPrefixLength)
                    : prefix.PadLeft(outputOptions.MaxPrefixLength);
            }

            sb.Append(prefix)
            .Append(" ")
            .Append(ApplyTextFormatters(text, outputOptions.TextFormatters));

            return(sb.ToString());
        }
Example #2
0
 public ScenarioOutput(TestContext testContext, ScenarioOutputOptions outputOptions)
 {
     _testContext   = testContext;
     _outputOptions = outputOptions;
 }