public override void DoTable(Parse theTable) { Parse embeddedTables = GetEmbeddedTables(theTable); Parse expectedCell = GetExpectedCell(theTable); var writer = new StoryTestCopyWriter(); var storyTest = new StoryTest(Processor, writer) .WithParsedInput(new Parse("div", string.Empty, embeddedTables, null)); storyTest.Execute(new Service.Service(Processor)); SetEmbeddedTables(theTable, writer.ResultTables); if (expectedCell != null) { var actual = new FixtureTable(writer.ResultTables); var expected = new FixtureTable(expectedCell.Parts); string differences = actual.Differences(expected); if (differences.Length == 0) { Right(expectedCell); } else { Wrong(expectedCell); expectedCell.More = ParseNode.MakeCells(Escape(differences)); expectedCell.More.SetAttribute(CellAttribute.Status, TestStatus.Wrong); } } }
[Test] public void StackTraceEmptyExpectedMatches() { var table1 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same<span class=\"fit_stacktrace\">stack trace blah blah</span></td></tr></table>")); var table2 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same<span class=\"fit_stacktrace\"></span></td></tr></table>>")); Assert.AreEqual(string.Empty, table1.Differences(table2)); }
[Test] public void StackTraceWithoutExceptionNameMatches() { var table1 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same<span class=\"fit_stacktrace\">x.y.z: stack: trace</span></td></tr></table>")); var table2 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same<span class=\"fit_stacktrace\">stack: trace</span></td></tr></table>>")); Assert.AreEqual(string.Empty, table1.Differences(table2)); }
[Test] public void EmptyTableCellsMatch() { var table1 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same</td><td></td></tr></table>")); var table2 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same</td><td></td></tr></table>")); Assert.AreEqual(string.Empty, table1.Differences(table2)); }
[Test] public void TableCellTagsDifferent() { var table1 = new FixtureTable(Parse.ParseFrom( "<table><tr><td class=\"actual\">same</td></tr></table>")); var table2 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same</td></tr></table>")); Assert.AreEqual("in <table>, in <tr>, expected: '<td>', was '<td class=\"actual\">'", table1.Differences(table2)); }
[Test] public void TableCellsDifferent() { var table1 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same</td><td>actual</td></tr></table>")); var table2 = new FixtureTable(Parse.ParseFrom( "<table><tr><td>same</td><td>expected</td></tr></table>")); Assert.AreEqual("in <table>, in <tr>, in <td> body, expected: 'expected', was 'actual'", table1.Differences(table2)); }
public void StackTraceNoneExpectedDifferent() { var table1 = new FixtureTable(new HtmlParser().Parse( "<table><tr><td>same<span class=\"fit_stacktrace\">stack trace blah blah</span></td></tr></table>")); var table2 = new FixtureTable(new HtmlParser().Parse( "<table><tr><td>same</td></tr></table>>")); Assert.AreEqual("in <table>, in <tr>, in <td> body, expected: null, was 'stack trace blah blah'", table1.Differences(table2)); }
public void AlternateStackTraceStartsWithExpectedMatches() { var table1 = new FixtureTable(new HtmlParser().Parse( "<table><tr><td>same<span class=\"fit_stacktrace\">stack trace blah blah</span></td></tr></table>")); var table2 = new FixtureTable(new HtmlParser().Parse( "<table><tr><td>same<span class=\"fit_label\">stack trace</span></td></tr></table>>")); Assert.AreEqual(string.Empty, table1.Differences(table2)); }
public TypedValue Check(CellOperationValue actualValue, Tree <Cell> expectedCell) { var cell = (Parse)expectedCell.Value; var expectedTable = new FixtureTable(cell.Parts); var tables = actualValue.GetActual <Parse>(Processor); var actualTable = new FixtureTable(tables); string differences = actualTable.Differences(expectedTable); if (differences.Length == 0) { Processor.TestStatus.MarkRight(expectedCell.Value); } else { Processor.TestStatus.MarkWrong(expectedCell.Value, differences); cell.More = new Parse("td", string.Empty, tables, null); } return(TypedValue.Void); }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { TypedValue actualValue = GetTypedActual(context, parameters); var cell = (Parse)parameters.Cell; var expected = new FixtureTable(cell.Parts); var tables = actualValue.GetValue <Parse>(); var actual = new FixtureTable(tables); string differences = actual.Differences(expected); if (differences.Length == 0) { Processor.TestStatus.MarkRight(parameters.Cell); } else { Processor.TestStatus.MarkWrong(parameters.Cell, differences); cell.More = new Parse("td", string.Empty, tables, null); } return(TypedValue.Void); }
public override void DoTable(Parse theTable) { Parse embeddedTables = GetEmbeddedTables(theTable); Parse expectedCell = GetExpectedCell(theTable); var storyTest = new StoryTest(embeddedTables, SpecifyWriter); storyTest.Execute(); SetEmbeddedTables(theTable, resultTables); if (expectedCell != null) { var actual = new FixtureTable(resultTables); var expected = new FixtureTable(expectedCell.Parts); string differences = actual.Differences(expected); if (differences.Length == 0) { Right(expectedCell); } else { Wrong(expectedCell); expectedCell.More = ParseNode.MakeCells(Escape(differences)); expectedCell.More.SetAttribute(CellAttributes.StatusKey, CellAttributes.WrongStatus); } } }
public void EmptyTablesMatch() { var table1 = new FixtureTable(null); var table2 = new FixtureTable(null); Assert.AreEqual(string.Empty, table1.Differences(table2)); }
public void EmptyAndNonEmptyDifferent() { var table1 = new FixtureTable(new HtmlParser().Parse("<table><tr><td>actual</td></tr></table>")); var table2 = new FixtureTable(null); Assert.AreEqual("expected: null, was '<table>'", table1.Differences(table2)); }