|
| 1 | +using System.Linq; |
| 2 | +using Shouldly; |
| 3 | +using TestStack.BDDfy.Reporters; |
| 4 | +using Xunit; |
| 5 | + |
| 6 | +namespace TestStack.BDDfy.Tests.Reporters |
| 7 | +{ |
| 8 | + using System.Collections.Generic; |
| 9 | + |
| 10 | + public class ReportModelMapperTests |
| 11 | + { |
| 12 | + private List<Story> _stories; |
| 13 | + |
| 14 | + public ReportModelMapperTests() |
| 15 | + { |
| 16 | + _stories = new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples() |
| 17 | + .ToList(); |
| 18 | + } |
| 19 | + |
| 20 | + [Fact] |
| 21 | + public void story_should_map_to_report_story() |
| 22 | + { |
| 23 | + var mapped = _stories.ToReportModel().Stories; |
| 24 | + |
| 25 | + mapped.Count.ShouldBe(2); |
| 26 | + for (int i = 0; i < 2; i++) |
| 27 | + { |
| 28 | + mapped[i].Namespace.ShouldBe(_stories[i].Namespace); |
| 29 | + mapped[i].Result.ShouldBe(_stories[i].Result); |
| 30 | + mapped[i].Scenarios.Count.ShouldBe(_stories[i].Scenarios.Count()); |
| 31 | + mapped[i].Metadata.ShouldNotBe(null); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + [Fact] |
| 36 | + public void story_metadata_should_map_to_report_story_metadata() |
| 37 | + { |
| 38 | + var mapped = _stories.ToReportModel().Stories; |
| 39 | + |
| 40 | + for (int i = 0; i < 2; i++) |
| 41 | + { |
| 42 | + mapped[i].Metadata.Narrative1.ShouldBe(_stories[i].Metadata.Narrative1); |
| 43 | + mapped[i].Metadata.Narrative2.ShouldBe(_stories[i].Metadata.Narrative2); |
| 44 | + mapped[i].Metadata.Narrative3.ShouldBe(_stories[i].Metadata.Narrative3); |
| 45 | + mapped[i].Metadata.Title.ShouldBe(_stories[i].Metadata.Title); |
| 46 | + mapped[i].Metadata.TitlePrefix.ShouldBe(_stories[i].Metadata.TitlePrefix); |
| 47 | + mapped[i].Metadata.Type.ShouldBe(_stories[i].Metadata.Type); |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + [Fact] |
| 52 | + public void scenario_should_map_to_report_scenario() |
| 53 | + { |
| 54 | + var scenarios = _stories[0].Scenarios.ToList(); |
| 55 | + var mapped = _stories.ToReportModel().Stories[0].Scenarios; |
| 56 | + |
| 57 | + for (int i = 0; i < 2; i++) |
| 58 | + { |
| 59 | + mapped[i].Id.ShouldBe(scenarios[i].Id); |
| 60 | + mapped[i].Title.ShouldBe(scenarios[i].Title); |
| 61 | + mapped[i].Example.ShouldNotBe(null); |
| 62 | + mapped[i].Duration.ShouldBe(scenarios[i].Duration); |
| 63 | + mapped[i].Result.ShouldBe(scenarios[i].Result); |
| 64 | + |
| 65 | + mapped[i].Tags.Count.ShouldBe(scenarios[i].Tags.Count); |
| 66 | + mapped[i].Steps.Count.ShouldBe(scenarios[i].Steps.Count); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + [Fact] |
| 71 | + public void step_should_map_to_report_step() |
| 72 | + { |
| 73 | + var steps = _stories[0].Scenarios.First().Steps; |
| 74 | + var mapped = _stories.ToReportModel().Stories[0].Scenarios.First().Steps; |
| 75 | + |
| 76 | + for (int i = 0; i < 2; i++) |
| 77 | + { |
| 78 | + mapped[i].Id.ShouldBe(steps[i].Id); |
| 79 | + mapped[i].Asserts.ShouldBe(steps[i].Asserts); |
| 80 | + mapped[i].ShouldReport.ShouldBe(steps[i].ShouldReport); |
| 81 | + mapped[i].Title.ShouldBe(steps[i].Title); |
| 82 | + mapped[i].ExecutionOrder.ShouldBe(steps[i].ExecutionOrder); |
| 83 | + mapped[i].Result.ShouldBe(steps[i].Result); |
| 84 | + mapped[i].Exception.ShouldBe(steps[i].Exception); |
| 85 | + mapped[i].Duration.ShouldBe(steps[i].Duration); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + [Fact] |
| 90 | + public void example_should_map_to_report_example() |
| 91 | + { |
| 92 | + var scenarios = _stories[0].Scenarios.ToList(); |
| 93 | + var mapped = _stories.ToReportModel().Stories[0].Scenarios; |
| 94 | + |
| 95 | + for (int i = 0; i < 2; i++) |
| 96 | + { |
| 97 | + mapped[i].Example.Headers.ShouldBe(scenarios[i].Example.Headers); |
| 98 | + mapped[i].Example.Values.ShouldBe(scenarios[i].Example.Values); |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | +} |
0 commit comments