Exemple #1
0
        public void Should_format_xml()
        {
            var result = new FeatureResult("Feature name", "feature\nlong description", "Label 1");

            result.AddScenario(new ScenarioResult("name", new[] { new StepResult(1, "step1", ResultStatus.Passed), new StepResult(2, "step2", ResultStatus.Ignored, "Not implemented yet") }, "Label 2"));
            result.AddScenario(new ScenarioResult("name2", new[] { new StepResult(1, "step3", ResultStatus.Passed), new StepResult(2, "step4", ResultStatus.Failed, "  Expected: True\n  But was: False") }, null));
            var text = _subject.Format(result);

            Console.WriteLine(text);

            const string expectedText = @"<?xml version=""1.0"" encoding=""utf-8""?>
<TestResults>
  <Feature Name=""Feature name"" Label=""Label 1"">
    <Description>feature
long description</Description>
    <Scenario Status=""Ignored"" Name=""name"" Label=""Label 2"">
      <Step Status=""Passed"" Number=""1"" Name=""step1"" />
      <Step Status=""Ignored"" Number=""2"" Name=""step2"" />
      <StatusDetails>Not implemented yet</StatusDetails>
    </Scenario>
    <Scenario Status=""Failed"" Name=""name2"">
      <Step Status=""Passed"" Number=""1"" Name=""step3"" />
      <Step Status=""Failed"" Number=""2"" Name=""step4"" />
      <StatusDetails>  Expected: True
  But was: False</StatusDetails>
    </Scenario>
  </Feature>
</TestResults>";

            Assert.That(text, Is.EqualTo(expectedText));
        }
Exemple #2
0
        public void Should_format_feature_with_description()
        {
            var result = new FeatureResult("My feature", string.Format("My feature{0}long description", Environment.NewLine), "Label 1");

            result.AddScenario(new ScenarioResult("name", new[] { new StepResult(1, "step1", ResultStatus.Passed), new StepResult(2, "step2", ResultStatus.Ignored, "Not implemented yet") }, "Label 2"));
            result.AddScenario(new ScenarioResult("name2", new[] { new StepResult(1, "step3", ResultStatus.Passed), new StepResult(2, "step4", ResultStatus.Failed, string.Format("  Expected: True{0}  But was: False", Environment.NewLine)) }, null));
            var          text         = _subject.Format(result);
            const string expectedText = @"Feature: [Label 1] My feature
	My feature
	long description

	Scenario: [Label 2] name - Ignored
		Step 1: step1 - Passed
		Step 2: step2 - Ignored

		Details: Not implemented yet

	Scenario: name2 - Failed
		Step 1: step3 - Passed
		Step 2: step4 - Failed

		Details: Expected: True
			  But was: False
";

            Assert.That(text, Is.EqualTo(expectedText));
        }
        public void Should_format_xml()
        {
            var result = ResultFormatterTestData.GetFeatureResultWithDescription();
            var text   = _subject.Format(result);

            Debug.WriteLine(text);

            const string expectedText = @"<?xml version=""1.0"" encoding=""utf-8""?>
<TestResults>
  <Summary TestExecutionStart=""2014-09-23T19:21:58.055Z"" TestExecutionTime=""PT1M4.257S"">
    <Features Count=""1"" />
    <Scenarios Count=""2"" Passed=""0"" Bypassed=""0"" Failed=""1"" Ignored=""1"" />
    <Steps Count=""5"" Passed=""1"" Bypassed=""1"" Failed=""1"" Ignored=""1"" NotRun=""1"" />
  </Summary>
  <Feature Name=""My feature"" Label=""Label 1"">
    <Description>My feature
long description</Description>
    <Scenario Status=""Ignored"" Name=""name"" Label=""Label 2"" ExecutionStart=""2014-09-23T19:21:58.055Z"" ExecutionTime=""PT1M2.1S"">
      <Category Name=""categoryA"" />
      <Step Status=""Passed"" Number=""1"" Name=""call step1 &quot;arg1&quot;"" ExecutionStart=""2014-09-23T19:21:59.055Z"" ExecutionTime=""PT1M1S"">
        <StepName StepType=""call"" Format=""step1 &quot;{0}&quot;"">
          <Parameter IsEvaluated=""true"">arg1</Parameter>
        </StepName>
        <Comment>multiline
comment</Comment>
        <Comment>comment 2</Comment>
      </Step>
      <Step Status=""Ignored"" Number=""2"" Name=""step2"" ExecutionStart=""2014-09-23T19:22:00.055Z"" ExecutionTime=""PT1.1S"">
        <StatusDetails>Not implemented yet</StatusDetails>
        <StepName Format=""step2"" />
      </Step>
      <StatusDetails>Step 2: Not implemented yet</StatusDetails>
    </Scenario>
    <Scenario Status=""Failed"" Name=""name2"" ExecutionStart=""2014-09-23T19:22:01.055Z"" ExecutionTime=""PT2.157S"">
      <Category Name=""categoryB"" />
      <Category Name=""categoryC"" />
      <Step Status=""Bypassed"" Number=""1"" Name=""step3"" ExecutionStart=""2014-09-23T19:22:02.055Z"" ExecutionTime=""PT2.107S"">
        <StatusDetails>bypass reason</StatusDetails>
        <StepName Format=""step3"" />
      </Step>
      <Step Status=""Failed"" Number=""2"" Name=""step4"" ExecutionStart=""2014-09-23T19:22:03.055Z"" ExecutionTime=""PT0.05S"">
        <StatusDetails>  Expected: True
  But was: False</StatusDetails>
        <StepName Format=""step4"" />
      </Step>
      <Step Status=""NotRun"" Number=""3"" Name=""step5"">
        <StepName Format=""step5"" />
      </Step>
      <StatusDetails>Step 1: bypass reason
Step 2: Expected: True
	  But was: False</StatusDetails>
    </Scenario>
  </Feature>
</TestResults>";

            Assert.That(text, Is.EqualTo(expectedText));
            ValidateWithSchema(text);
        }
        public void Should_format_feature_with_description()
        {
            var result = ResultFormatterTestData.GetFeatureResultWithDescription();
            var text   = _subject.Format(result);

            Debug.WriteLine(text);
            const string expectedText = @"Summary:
	Test execution start time: 2014-09-23 19:21:58 UTC
	Test execution time      : 1m 04s
	Number of features       : 1
	Number of scenarios      : 2
	Passed scenarios         : 0
	Bypassed scenarios       : 0
	Failed scenarios         : 1
	Ignored scenarios        : 1
	Number of steps          : 5
	Passed steps             : 1
	Bypassed steps           : 1
	Failed steps             : 1
	Ignored steps            : 1
	Not Run steps            : 1

Feature: My feature [Label 1]
	My feature
	long description

	Scenario: name [Label 2] - Ignored (1m 02s)
		Categories: categoryA
		Step 1: call step1 ""arg1"" - Passed (1m 01s)
		Step 2: step2 - Ignored (1s 100ms)
		Details:
			Step 2: Not implemented yet
		Comments:
			Step 1: multiline
				comment
			Step 1: comment 2

	Scenario: name2 - Failed (2s 157ms)
		Categories: categoryB, categoryC
		Step 1: step3 - Bypassed (2s 107ms)
		Step 2: step4 - Failed (50ms)
		Step 3: step5 - NotRun
		Details:
			Step 1: bypass reason
			Step 2: Expected: True
				  But was: False
";

            Assert.That(text, Is.EqualTo(expectedText));
        }
Exemple #5
0
        private string FormatAndExtractText(params IFeatureResult[] results)
        {
            var formatted = _subject.Format(results);
            var doc       = new HtmlDocument();

            doc.LoadHtml(formatted);
            var body    = doc.DocumentNode.SelectSingleNode("//body");
            var builder = FormatAllNodes(new HtmlToPlainTextFormatter(), body);

            Debug.WriteLine(builder.ToString());
            return(builder.ToString());
        }
Exemple #6
0
        public void OutPutCSVFileTest()
        {
            var input = new List <string> {
                "David,Rudd,60050,9%,01 March - 31 March", "Ryan,Chen,120000,10%,01 March - 31 March"
            };
            var expect = new List <string> {
                "David Rudd,01 March - 31 March,5004,922,4082,450", "Ryan Chen,01 March - 31 March,10000,2696,7304,1000"
            };

            var sut = _paySlipCalculator.Convert(input);

            _resultFormatter.Format(sut);
        }
Exemple #7
0
 /// <summary>
 /// Writes a Result to the output
 /// </summary>
 /// <param name="result">SPARQL Result</param>
 /// <returns></returns>
 protected override bool HandleResultInternal(SparqlResult result)
 {
     if (_currentType == SparqlResultsType.Boolean)
     {
         throw new RdfParseException("Cannot handle a Result when the handler has already handled a boolean result");
     }
     _currentType = SparqlResultsType.VariableBindings;
     if (!_headerWritten && _formatter is IResultSetFormatter)
     {
         _writer.WriteLine(((IResultSetFormatter)_formatter).FormatResultSetHeader(_currVariables.Distinct()));
         _headerWritten = true;
     }
     _writer.WriteLine(_formatter.Format(result));
     return(true);
 }
Exemple #8
0
        public virtual async Task <string> RunAndPrintCommandAsync(IConfiguration config, IPrinter printer, CancellationToken ct = default(CancellationToken))
        {
            Connection connect = this.API.CreateConnection(config);

            CommandValues.GenericInfoCommandValue info = await this.Creator.Create(config, connect, ct);

            string returnString = FormatToString.Format(info);

            if (printer != null)
            {
                await printer.PrintAsync(returnString);
            }

            return(returnString);
        }
Exemple #9
0
        public GameResult Play(Piece originalPiece, string moveCommands, Direction startingDirection)
        {
            _gameboard.Add(originalPiece);

            string reducedCommands           = _commandReducer.Reduce(moveCommands, startingDirection);
            IEnumerable <Point> moveSequence = _commandToCoordinateMapper.Map(reducedCommands);

            Piece target = _gameboard.Get(originalPiece.Position);

            foreach (var movingVector in moveSequence)
            {
                target = _gameboard.MovePiece(target.Position, movingVector);
            }

            return(new GameResult
            {
                Piece = target,
                Result = _resultFormatter.Format(target)
            });
        }
Exemple #10
0
 /// <summary>
 /// Saves test results summary to specified file, using formatter defined in constructor.
 /// </summary>
 /// <param name="filePath">Output file path.</param>
 public void SaveSummary(string filePath)
 {
     File.WriteAllText(filePath, _formatter.Format(_results.ToArray()), Encoding.UTF8);
 }
 /// <summary>
 /// Saves formatted feature <c>results</c> to file specified in constructor.
 /// If output path refers to directory which does not exist, it will be created.
 /// </summary>
 /// <param name="results">Results to save.</param>
 public void Save(params IFeatureResult[] results)
 {
     EnsureOutputDirectoryExists();
     File.WriteAllText(_outputPath, _formatter.Format(results), Encoding.UTF8);
 }