public SucceedsIfValidCommandRegardlessOfIgnoreWarnings()
 {
     Examples = new ExampleTable("Ignore Warnings")
     {
         true, false
     };
 }
Esempio n. 2
0
        public void Map_ExampleTableWithDataRows_ReturnsJsonTableWithDataRows()
        {
            var table = new ExampleTable
            {
                DataRows = new List <TableRow>
                {
                    new TableRowWithTestResult("cell 1-1", "cell 1-2"),
                    new TableRowWithTestResult("cell 2-1", "cell 2-2")
                }
            };

            var testResult = new JsonTestResult
            {
                WasExecuted   = false,
                WasSuccessful = false
            };

            var mapper = CreateMapper();
            var actual = mapper.MapWithTestResults(table);

            Check.That(actual.DataRows.Count).IsEqualTo(2);

            Check.That(actual.DataRows[0].Count).IsEqualTo(3);
            Check.That(actual.DataRows[0].OfType <string>()).ContainsExactly("cell 1-1", "cell 1-2");
            Check.That((actual.DataRows[0] as JsonTableRowWithTestResult).Result.WasSuccessful).Equals(false);
            Check.That((actual.DataRows[0] as JsonTableRowWithTestResult).Result.WasExecuted).Equals(false);

            Check.That(actual.DataRows[1].Count).IsEqualTo(3);
            Check.That(actual.DataRows[1].OfType <string>()).ContainsExactly("cell 2-1", "cell 2-2");
            Check.That((actual.DataRows[1] as JsonTableRowWithTestResult).Result.WasSuccessful).Equals(false);
            Check.That((actual.DataRows[1] as JsonTableRowWithTestResult).Result.WasExecuted).Equals(false);
        }
        public void ThenIgnoredScenarioOutlineIsSetToInconclusive()
        {
            var results = ParseResultsFile();

            var feature = new Feature {
                Name = "Example With Ignored Scenario Outline"
            };
            var scenarioOutline = new ScenarioOutline {
                Name = "Add two numbers", Feature = feature
            };

            scenarioOutline.Steps = new List <Step>();

            var examples = new ExampleTable();

            examples.HeaderRow = new TableRow();
            examples.HeaderRow.Cells.Add("TestCase");
            var row = new TableRowWithTestResult();

            row.Cells.Add("1");
            examples.DataRows = new List <TableRow>();
            examples.DataRows.Add(row);

            scenarioOutline.Examples = new List <Example>();
            scenarioOutline.Examples.Add(new Example()
            {
                TableArgument = examples
            });

            var matchedExampleResult = results.GetExampleResult(scenarioOutline, new string[] { "1" });

            Check.That(matchedExampleResult).IsEqualTo(TestResult.Inconclusive);
        }
        public void ThenCanFormatScenarioOutlineWithMissingNameCorrectly()
        {
            var table = new ExampleTable
            {
                HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4"),
                DataRows  =
                    new List <TableRow>(new[]
                {
                    new TableRow("1", "2", "3", "4"),
                    new TableRow("5", "6", "7", "8")
                })
            };

            var example = new Example {
                Name = "Some examples", Description = "An example", TableArgument = table
            };
            var examples = new List <Example>();

            examples.Add(example);

            var scenarioOutline = new ScenarioOutline
            {
                Description = "We need to make sure that scenario outlines work properly",
                Examples    = examples
            };

            var htmlScenarioOutlineFormatter = Container.Resolve <HtmlScenarioOutlineFormatter>();
            var output = htmlScenarioOutlineFormatter.Format(scenarioOutline, 0);

            Check.That(output).ContainsGherkinScenario();
            Check.That(output).ContainsGherkinTable();
        }
 public FailsIfErrorsRegardlessOfIgnoreWarnings()
 {
     Examples = new ExampleTable("Ignore Warnings")
     {
         true, false
     };
 }
Esempio n. 6
0
 public StubUserStoryScenarioForWithExamples()
 {
     Examples = new ExampleTable("First Example", "Second Example")
     {
         { 1, "foo" },
         { 2, "bar" }
     };
 }
Esempio n. 7
0
        public virtual async Task <ExampleTable> Update(ExampleTable record)
        {
            if (record == null)
            {
                throw new NullReferenceException("Null record object");
            }

            return(await _repository.UpdateAsync(record));
        }
Esempio n. 8
0
        public virtual async Task Delete(ExampleTable record)
        {
            if (record == null)
            {
                throw new NullReferenceException("Null record object");
            }

            await _repository.DeleteAsync(record);
        }
        public void ThenSingleScenarioOutlineWithStepsAddedSuccessfully()
        {
            var excelScenarioFormatter = Container.Resolve <ExcelScenarioOutlineFormatter>();
            var exampleTable           = new ExampleTable();

            exampleTable.HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4");
            exampleTable.DataRows  =
                new List <TableRow>(new[] { new TableRowWithTestResult("1", "2", "3", "4"), new TableRowWithTestResult("5", "6", "7", "8") });
            var example = new Example {
                Name = "Examples", Description = string.Empty, TableArgument = exampleTable
            };
            var examples = new List <Example>();

            examples.Add(example);
            var scenarioOutline = new ScenarioOutline
            {
                Name        = "Test Feature",
                Description =
                    "In order to test this feature,\nAs a developer\nI want to test this feature",
                Examples = examples
            };
            var given = new Step {
                NativeKeyword = "Given", Name = "a precondition"
            };
            var when = new Step {
                NativeKeyword = "When", Name = "an event occurs"
            };
            var then = new Step {
                NativeKeyword = "Then", Name = "a postcondition"
            };

            scenarioOutline.Steps = new List <Step>(new[] { given, when, then });

            using (var workbook = new XLWorkbook())
            {
                IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
                int          row       = 3;
                excelScenarioFormatter.Format(worksheet, scenarioOutline, ref row);

                Check.That(worksheet.Cell("B3").Value).IsEqualTo(scenarioOutline.Name);
                Check.That(worksheet.Cell("C4").Value).IsEqualTo(scenarioOutline.Description);
                Check.That(worksheet.Cell("B9").Value).IsEqualTo("Examples");
                Check.That(worksheet.Cell("D10").Value).IsEqualTo("Var1");
                Check.That(worksheet.Cell("E10").Value).IsEqualTo("Var2");
                Check.That(worksheet.Cell("F10").Value).IsEqualTo("Var3");
                Check.That(worksheet.Cell("G10").Value).IsEqualTo("Var4");
                Check.That(worksheet.Cell("D11").Value).IsEqualTo(1.0);
                Check.That(worksheet.Cell("E11").Value).IsEqualTo(2.0);
                Check.That(worksheet.Cell("F11").Value).IsEqualTo(3.0);
                Check.That(worksheet.Cell("G11").Value).IsEqualTo(4.0);
                Check.That(worksheet.Cell("D12").Value).IsEqualTo(5.0);
                Check.That(worksheet.Cell("E12").Value).IsEqualTo(6.0);
                Check.That(worksheet.Cell("F12").Value).IsEqualTo(7.0);
                Check.That(worksheet.Cell("G12").Value).IsEqualTo(8.0);
                Check.That(row).IsEqualTo(13);
            }
        }
Esempio n. 10
0
        public static TScenario WithExamples <TScenario>(this TScenario testObject, ExampleTable table)
            where TScenario : class
        {
            var testContext = TestContext.GetContext(testObject);

            testContext.Examples = table;

            return(testObject);
        }
Esempio n. 11
0
        public void TableToString()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                { 1, 2 },
                { 3, 4 }
            };

            table.ToString().ShouldMatchApproved();
        }
Esempio n. 12
0
        public void TableToStringWithAdditionalColumn()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                { 1, 2 },
                { 3, 4 }
            };

            Approvals.Verify(table.ToString(new[] { "Additional" }, new[] { new[] { "SomeAdditional Value" } }));
        }
        public void TableToString()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                {1, 2},
                {3, 4}
            };

            Approvals.Verify(table.ToString());
        }
Esempio n. 14
0
        public void TableToString()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                {1, 2},
                {3, 4}
            };

            table.ToString().ShouldMatchApproved();
        }
        public void TableToStringWithAdditionalColumn()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                {1, 2},
                {3, 4}
            };

            Approvals.Verify(table.ToString(new[] {"Additional"}, new[] {new[] {"SomeAdditional Value"}}));
        }
Esempio n. 16
0
        public void TableToString()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                { 1, 2 },
                { 3, 4 }
            };

            Approvals.Verify(table.ToString());
        }
Esempio n. 17
0
        public void TableToStringWithAdditionalColumn()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                {1, 2},
                {3, 4}
            };

            table.ToString(new[] {"Additional"}, new[] {new[] {"SomeAdditional Value"}})
                .ShouldMatchApproved();
        }
Esempio n. 18
0
        public void TableToStringWithAdditionalColumn()
        {
            var table = new ExampleTable("Header 1", "Header 2")
            {
                { 1, 2 },
                { 3, 4 }
            };

            table.ToString(new[] { "Additional" }, new[] { new[] { "SomeAdditional Value" } })
            .ShouldMatchApproved();
        }
        public void GetPersianDateScenario()
        {
            var exampleTable = new ExampleTable("ConvertUrl", "GregorianDate", "PersianDate")
            {
                { "convert", "1985/01/01", "01/01/01" },
                { "convert", "1985/01/01", "01/01/02" },
            };

            new GetPersianDateScenario().WithExamples(exampleTable)
            .WithTags("Tag1").BDDfy <GetPersianDateFromGregorianDateStory>();
        }
Esempio n. 20
0
        private Scenario[] GetScenarios(bool includeFailingScenario, bool includeExamples)
        {
            var sadExecutionSteps = GetSadExecutionSteps().ToList();

            if (includeFailingScenario)
            {
                var last = sadExecutionSteps.Last();
                last.Result = Result.Failed;
                try
                {
                    throw new InvalidOperationException("Boom");
                }
                catch (Exception ex)
                {
                    last.Exception = ex;
                }
            }

            if (includeExamples)
            {
                var exampleId    = _idCount++.ToString();
                var exampleTable = new ExampleTable("sign", "action")
                {
                    { "positive", "is" },
                    { "negative", "is not" }
                };
                var exampleExecutionSteps = GetExampleExecutionSteps().ToList();
                if (includeFailingScenario)
                {
                    var last = exampleExecutionSteps.Last();
                    last.Result = Result.Failed;
                    try
                    {
                        throw new InvalidOperationException("Boom\nWith\r\nNew lines");
                    }
                    catch (Exception ex)
                    {
                        last.Exception = ex;
                    }
                }
                return(new List <Scenario>
                {
                    new Scenario(exampleId, typeof(ExampleScenario), GetExampleExecutionSteps(), "Example Scenario", exampleTable.ElementAt(0), new List <string>()),
                    new Scenario(exampleId, typeof(ExampleScenario), exampleExecutionSteps, "Example Scenario", exampleTable.ElementAt(1), new List <string>())
                }.ToArray());
            }

            return(new List <Scenario>
            {
                new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario", new List <string>()),
                new Scenario(typeof(SadPathScenario), sadExecutionSteps, "Sad Path Scenario", new List <string>())
            }.ToArray());
        }
Esempio n. 21
0
        public void should_handle_specification_with_examples()
        {
            var examples = new ExampleTable();
            var spec     = Substitute.For <IScenario>();

            spec.Examples.Returns(examples);
            var sut = new BddfyTestEngine();

            sut.Execute(spec);

            spec.Received().WithExamples(examples);
        }
Esempio n. 22
0
        public JsonTable MapWithTestResults(ExampleTable table)
        {
            if (table == null)
            {
                return(null);
            }

            return(new JsonTable
            {
                HeaderRow = this.tableHeaderMapper.Map(table.HeaderRow),
                DataRows = (table.DataRows ?? new List <TableRow>()).Select(x => this.tableRowMapper.MapwWithTestResult(x as TableRowWithTestResult)).ToList()
            });
        }
        public string AddData()
        {
            var databaseManager = Application.Ioc.Resolve <DatabaseManager>();

            using (var context = databaseManager.CreateContext()) {
                var data = new ExampleTable()
                {
                    Name       = "test",
                    CreateTime = DateTime.UtcNow,
                    Deleted    = false
                };
                context.Save(ref data);
            }
            return("success");
        }
        public void MethodD()
        {
            var testManager = Application.Ioc.Resolve <TestManager>();

            using (testManager.UseTemporaryDatabase()) {
                var databaseManager = Application.Ioc.Resolve <DatabaseManager>();
                using (var context = databaseManager.CreateContext()) {
                    var obj = new ExampleTable()
                    {
                        Name = "obj in temporary database"
                    };
                    context.Save(ref obj);
                }
            }
        }
        public void ThenSingleScenarioOutlineAddedSuccessfully()
        {
            var excelScenarioFormatter = Container.Resolve <ExcelScenarioOutlineFormatter>();
            var exampleTable           = new ExampleTable();

            exampleTable.HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4");
            exampleTable.DataRows  =
                new List <TableRow>(new[] { new TableRowWithTestResult("1", "2", "3", "4"), new TableRowWithTestResult("5", "6", "7", "8") });
            var example = new Example {
                Name = "Examples", Description = string.Empty, TableArgument = exampleTable
            };
            var examples = new List <Example>();

            examples.Add(example);
            var scenarioOutline = new ScenarioOutline
            {
                Name        = "Test Feature",
                Description =
                    "In order to test this feature,\nAs a developer\nI want to test this feature",
                Examples = examples,
                Tags     = { "tag1", "tag2" }
            };

            using (var workbook = new XLWorkbook())
            {
                IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
                int          row       = 3;
                excelScenarioFormatter.Format(worksheet, scenarioOutline, ref row);

                Check.That(worksheet.Cell("B3").Value).IsEqualTo(scenarioOutline.Name);
                Check.That(worksheet.Cell("C4").Value).IsEqualTo("tag1, tag2");
                Check.That(worksheet.Cell("C5").Value).IsEqualTo(scenarioOutline.Description);
                Check.That(worksheet.Cell("B7").Value).IsEqualTo("Examples");
                Check.That(worksheet.Cell("D8").Value).IsEqualTo("Var1");
                Check.That(worksheet.Cell("E8").Value).IsEqualTo("Var2");
                Check.That(worksheet.Cell("F8").Value).IsEqualTo("Var3");
                Check.That(worksheet.Cell("G8").Value).IsEqualTo("Var4");
                Check.That(worksheet.Cell("D9").Value).IsEqualTo(1.0);
                Check.That(worksheet.Cell("E9").Value).IsEqualTo(2.0);
                Check.That(worksheet.Cell("F9").Value).IsEqualTo(3.0);
                Check.That(worksheet.Cell("G9").Value).IsEqualTo(4.0);
                Check.That(worksheet.Cell("D10").Value).IsEqualTo(5.0);
                Check.That(worksheet.Cell("E10").Value).IsEqualTo(6.0);
                Check.That(worksheet.Cell("F10").Value).IsEqualTo(7.0);
                Check.That(worksheet.Cell("G10").Value).IsEqualTo(8.0);
                Check.That(row).IsEqualTo(11);
            }
        }
Esempio n. 26
0
 public ForPrimitive()
 {
     Examples = new ExampleTable("Primitive")
     {
         true,
         byte.MinValue,
         sbyte.MinValue,
         short.MinValue,
         ushort.MinValue,
         int.MinValue,
         uint.MinValue,
         long.MinValue,
         ulong.MinValue,
         new IntPtr(int.MaxValue),
         new UIntPtr(uint.MaxValue),
         char.MinValue,
         double.MinValue,
         float.MinValue
     };
 }
Esempio n. 27
0
        public void InitializesScenarioWithExampleBeforeRunning()
        {
            const int expectedValue = 1;
            var actualValue = 0;
            var exampleTable = new ExampleTable("ExampleValue")
            {
                expectedValue
            }.Single();

            var sut = new TestRunner();
            Func<object, object> action = o => actualValue = ExampleValue;
            var steps = new List<Step> { new Step(action, new StepTitle("A Step"), true, ExecutionOrder.Initialize, true, new List<StepArgument>()) };

            var scenarioWithExample = new Scenario("id", this, steps, "Scenario Text", exampleTable, new List<string>());
            var story = new Story(new StoryMetadata(typeof(TestRunnerTests), new StoryNarrativeAttribute()), scenarioWithExample);

            sut.Process(story);

            actualValue.ShouldBe(expectedValue);
        }
Esempio n. 28
0
        public string Uow()
        {
            // insert data
            var    uow     = Application.Ioc.Resolve <IUnitOfWork>();
            var    service = Application.Ioc.Resolve <IDomainService <ExampleTable, long> >();
            string name    = RandomUtils.RandomString(5);

            using (uow.Scope()) {
                var data = new ExampleTable()
                {
                    Name = name
                };
                service.Save(ref data);
            }
            // read inserted data
            using (uow.Scope()) {
                var readData = service.Get(t => t.Name == name);
                return(JsonConvert.SerializeObject(new { readData }));
            }
        }
Esempio n. 29
0
        public IActionResult Post([FromBody] ExampleTable row, [FromQuery] bool?useEFCore)
        {
            var stopwatch = Stopwatch.StartNew();

            if (useEFCore.GetValueOrDefault())
            {
                _repository.ExampleTable.Add(row);
                _repository.SaveChanges();
            }
            else
            {
                using (var db = new SqlConnection(_options.Value.ConnectionString))
                {
                    row.Id = db.Query <int>(@"INSERT INTO dbo.ExampleTable (Created, Message, IsEfCore) VALUES (@Created, @Message, @IsEfCore); SELECT SCOPE_IDENTITY()", row).Single();
                }
            }
            stopwatch.Stop();
            Console.WriteLine($"Finished POST in {stopwatch.ElapsedMilliseconds}ms.");
            return(Ok(row));
        }
        public void CorrectlyReportsErrorWhenAllStepsNotRun()
        {
            Should.Throw <InvalidOperationException>(() =>
            {
                var exampleTable = new ExampleTable("Arg1", "Arg2")
                {
                    { "foo", "bar" },
                    { "foo", "bar" }
                };

                string arg1 = null;
                string arg2 = null;
                var arg3    = default(string);
                this.Given(_ => AFailingStep(arg1), "Given a failing step")
                .Then(_ => NonExecutedStep(arg2), "Then multiple assertions")
                .And(_ => NonExecutedStep(arg3), "The second one blows up")
                .WithExamples(exampleTable)
                .BDDfy();
            });
        }
        public void CorrectlyReportsErrorWhenAllStepsNotRun()
        {
            Should.Throw<InvalidOperationException>(() =>
            {
                var exampleTable = new ExampleTable("Arg1", "Arg2")
                {
                    {"foo", "bar"},
                    {"foo", "bar"}
                };

                string arg1 = null;
                string arg2 = null;
                var arg3 = default(string);
                this.Given(_ => AFailingStep(arg1), "Given a failing step")
                    .Then(_ => NonExecutedStep(arg2), "Then multiple assertions")
                    .And(_ => NonExecutedStep(arg3), "The second one blows up")
                    .WithExamples(exampleTable)
                    .BDDfy();
            });
        }
Esempio n. 32
0
        public void CanParseTable()
        {
            const string table = @"
| Header 1 | Header 2     | Header3   |
| Value 1  | 2            | 3          |
|          | 14 Mar 2010  | Transition |";

            var exampleTable = ExampleTable.Parse(table);

            exampleTable.Headers.ShouldBe(new[] { "Header 1", "Header 2", "Header3" });
            exampleTable.ElementAt(0).GetValueOf(0, typeof(string)).ShouldBe("Value 1");
            exampleTable.ElementAt(0).GetValueOf(1, typeof(int)).ShouldBe(2);
            exampleTable.ElementAt(0).GetValueOf(2, typeof(decimal)).ShouldBe(3m);
            exampleTable.ElementAt(1).GetValueOf(0, typeof(string)).ShouldBe(null);
            exampleTable.ElementAt(1).GetValueOf(0, typeof(int?)).ShouldBe(null);
            exampleTable.ElementAt(1).GetValueOf(2, typeof(ExecutionOrder)).ShouldBe(ExecutionOrder.Transition);
            var argException = Should.Throw <ArgumentException>(() => exampleTable.ElementAt(1).GetValueOf(0, typeof(int)));

            argException.Message.ShouldBe("Cannot convert <null> to Int32 (Column: 'Header 1', Row: 2)");
            exampleTable.ElementAt(1).GetValueOf(1, typeof(DateTime)).ShouldBe(new DateTime(2010, 3, 14));
        }
        public void ThenMatchWillBeFoundEvenIfACarriageReturnWasFoundInValueField()
        {
            var results = ParseResultsFile();

            var feature = new Feature {
                Name = "Example With Empty Value"
            };
            var scenarioOutline = new ScenarioOutline {
                Name = "Testing test", Feature = feature
            };

            scenarioOutline.Steps = new List <Step>();

            var examples = new ExampleTable();

            examples.HeaderRow = new TableRow();
            examples.HeaderRow.Cells.Add("result1");
            examples.HeaderRow.Cells.Add("result2");
            examples.HeaderRow.Cells.Add("result3");
            var row = new TableRowWithTestResult();

            row.Cells.Add("1");
            row.Cells.Add("2");
            row.Cells.Add("3");
            examples.DataRows = new List <TableRow>();
            examples.DataRows.Add(row);
            row = new TableRowWithTestResult();
            row.Cells.Add("1");
            row.Cells.Add("");
            row.Cells.Add("4");
            examples.DataRows.Add(row);

            scenarioOutline.Examples = new List <Example>();
            scenarioOutline.Examples.Add(new Example()
            {
                TableArgument = examples
            });

            var actualResult = results.GetExampleResult(scenarioOutline, new string[] { "1", "", "4" });
        }
Esempio n. 34
0
        public void InitializesScenarioWithExampleBeforeRunning()
        {
            const int expectedValue = 1;
            var       actualValue   = 0;
            var       exampleTable  = new ExampleTable("ExampleValue")
            {
                expectedValue
            }.Single();

            var sut = new TestRunner();
            Func <object, object> action = o => actualValue = ExampleValue;
            var steps = new List <Step> {
                new Step(action, new StepTitle("A Step"), true, ExecutionOrder.Initialize, true, new List <StepArgument>())
            };

            var scenarioWithExample = new Scenario("id", this, steps, "Scenario Text", exampleTable, new List <string>());
            var story = new Story(new StoryMetadata(typeof(TestRunnerTests), new StoryNarrativeAttribute()), scenarioWithExample);

            sut.Process(story);

            actualValue.ShouldBe(expectedValue);
        }
Esempio n. 35
0
        public void Format(IXLWorksheet worksheet, ExampleTable table, ref int row)
        {
            int startRow     = row;
            int headerColumn = TableStartColumn;

            foreach (string cell in table.HeaderRow.Cells)
            {
                worksheet.Cell(row, headerColumn).Style.Font.SetBold();
                worksheet.Cell(row, headerColumn).Style.Font.SetItalic();
                worksheet.Cell(row, headerColumn).Style.Fill.SetBackgroundColor(XLColor.AliceBlue);
                worksheet.Cell(row, headerColumn++).Value = cell;
            }

            row++;

            foreach (TableRow dataRow in table.DataRows)
            {
                int dataColumn = TableStartColumn;
                foreach (string cell in dataRow.Cells)
                {
                    worksheet.Cell(row, dataColumn++).Value = cell;
                }

                row++;
            }

            int lastRow    = row - 1;
            int lastColumn = headerColumn - 1;

            worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.TopBorder =
                XLBorderStyleValues.Thin;
            worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.LeftBorder =
                XLBorderStyleValues.Thin;
            worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.BottomBorder =
                XLBorderStyleValues.Thin;
            worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.RightBorder =
                XLBorderStyleValues.Thin;
        }
 private void WhenSomethingHappens()
 {
     _exampleTable       = new ExampleTable();
     _subsitute.Examples = _exampleTable;
 }
 private void WhenSomethingHappens()
 {
     _exampleTable = new ExampleTable();
     _subsitute.Examples = _exampleTable;
 }
Esempio n. 38
0
        private Scenario[] GetScenarios(bool includeFailingScenario, bool includeExamples)
        {
            var sadExecutionSteps = GetSadExecutionSteps().ToList();
            if (includeFailingScenario)
            {
                var last = sadExecutionSteps.Last();
                last.Result = Result.Failed;
                try
                {
                    throw new InvalidOperationException("Boom");
                }
                catch (Exception ex)
                {
                    last.Exception = ex;
                }
            }

            if (includeExamples)
            {
                var exampleId = _idCount++.ToString();
                var exampleTable = new ExampleTable("sign", "action")
                                       {
                                            {"positive", "is"},
                                            {"negative", "is not"}
                                       };
                var exampleExecutionSteps = GetExampleExecutionSteps().ToList();
                if (includeFailingScenario)
                {
                    var last = exampleExecutionSteps.Last();
                    last.Result = Result.Failed;
                    try
                    {
                        throw new InvalidOperationException("Boom\nWith\r\nNew lines");
                    }
                    catch (Exception ex)
                    {
                        last.Exception = ex;
                    }
                }
                return new List<Scenario>
                {
                    new Scenario(exampleId, typeof(ExampleScenario), GetExampleExecutionSteps(), "Example Scenario", exampleTable.ElementAt(0), new List<string>()),
                    new Scenario(exampleId, typeof(ExampleScenario), exampleExecutionSteps, "Example Scenario", exampleTable.ElementAt(1), new List<string>())
                }.ToArray();
            }

            return new List<Scenario>
                       {
                           new Scenario(typeof(HappyPathScenario), GetHappyExecutionSteps(), "Happy Path Scenario", new List<string>()),
                           new Scenario(typeof(SadPathScenario), sadExecutionSteps, "Sad Path Scenario", new List<string>())
                       }.ToArray();
        }