private void ProcessTestDocument(string document, Action <string, TestCounts> writer) { try { Tree <Cell> result = service.Compose(new StoryTestString(document)); var parse = result != null ? (Parse)result.Value : null; var storyTest = new StoryTest(parse, (tables, counts) => WriteResults(tables, counts, writer)); reporter.WriteLine(parse.Leader); if (suiteSetupIdentifier.IsStartOf(parse.Leader) || IMaybeProcessingSuiteSetup) { storyTest.ExecuteOnConfiguration(service.Configuration); } else { storyTest.Execute(service.Configuration); } } catch (Exception e) { var testStatus = new TestStatus(); var parse = new CellBase(parseError, "div"); parse.SetAttribute(CellAttribute.Body, parseError); testStatus.MarkException(parse, e); WriteResults(new CellTree().AddBranchValue(parse), testStatus.Counts, writer); } }
public void TestLoadHandler() { TestUtils.InitAssembliesAndNamespaces(); StringBuilder builder = new StringBuilder(); builder.Append("<table>"); builder.Append("<tr><td colspan=\"2\">cell handler loader</td></tr>"); builder.Append("<tr><td>load</td><td>substring handler</td></tr>"); builder.Append("</table>"); Assert.IsFalse(Context.Configuration.GetItem<Service.Service>().Compare(new TypedValue("abc"), TestUtils.CreateCell("..b.."))); StoryTest test = new StoryTest(new Parse(builder.ToString())); test.ExecuteOnConfiguration(); Assert.IsTrue(Context.Configuration.GetItem<Service.Service>().Compare(new TypedValue("abc"), TestUtils.CreateCell("..b.."))); }
public void TestRemoveHandler() { Configuration configuration = TestUtils.InitAssembliesAndNamespaces(); new Service.Service(configuration).AddOperator(new CompareSubstring()); var builder = new StringBuilder(); builder.Append("<table>"); builder.Append("<tr><td colspan=\"2\">CellHandlerLoader</td></tr>"); builder.Append("<tr><td>remove</td><td>SubstringHandler</td></tr>"); builder.Append("</table>"); Assert.IsTrue(new Service.Service(configuration).Compare(new TypedValue("abc"), TestUtils.CreateCell("..b.."))); var test = new StoryTest(new Parse(builder.ToString())); test.ExecuteOnConfiguration(configuration); Assert.IsFalse(new Service.Service(configuration).Compare(new TypedValue("abc"), TestUtils.CreateCell("..b.."))); }
public void TestLoadHandler() { Configuration configuration = TestUtils.InitAssembliesAndNamespaces(); var builder = new TestBuilder(); builder.Append("<table>"); builder.Append("<tr><td colspan=\"2\">cell handler loader</td></tr>"); builder.Append("<tr><td>load</td><td>substring handler</td></tr>"); builder.Append("</table>"); Assert.IsFalse(new Service.Service(configuration).Compare(new TypedValue("abc"), TestUtils.CreateCell("..b.."))); StoryTest test = builder.MakeStoryTest(); test.ExecuteOnConfiguration(configuration); Assert.IsTrue(new Service.Service(configuration).Compare(new TypedValue("abc"), TestUtils.CreateCell("..b.."))); }
private void ProcessTestDocument(string document, Action<string, TestCounts> writer) { try { Tree<Cell> result = service.Compose(new StoryTestString(document)); var parse = result != null ? (Parse)result.Value : null; var storyTest = new StoryTest(parse, (tables, counts) => WriteResults(tables, counts, writer)); reporter.WriteLine(parse.Leader); if (suiteSetupIdentifier.IsStartOf(parse.Leader) || IMaybeProcessingSuiteSetup) storyTest.ExecuteOnConfiguration(service.Configuration); else storyTest.Execute(service.Configuration); } catch (Exception e) { var testStatus = new TestStatus(); var parse = new Parse("div", "Unable to parse input. Input ignored.", null, null); testStatus.MarkException(parse, e); WriteResults(parse, testStatus.Counts, writer); } }
private void ProcessTestDocument(string document, StoryTestWriter writer) { try { Tree<Cell> result = service.Compose(new StoryTestString(document)); var parse = result != null ? (Parse)result.Value : null; var storyTest = new StoryTest(parse, writer); reporter.WriteLine(parse.Leader); if (suiteSetupIdentifier.IsStartOf(parse.Leader) || IMaybeProcessingSuiteSetup) storyTest.ExecuteOnConfiguration(service.Configuration); else storyTest.Execute(service.Configuration); } catch (Exception e) { var testStatus = new TestStatus(); var parse = new CellBase(parseError, "div"); parse.SetAttribute(CellAttribute.Body, parseError ); testStatus.MarkException(parse, e); writer.WriteTable(new CellTree(parse)); writer.WriteTest(new CellTree().AddBranchValue(parse), testStatus.Counts); } }
private void ExecutePage(StoryPageName pageName, StoryTestString input, Action <StoryTestString, TestCounts> handleResults, Action handleNoTest) { var service = new Service.Service(configuration); Tree <Cell> result = service.Compose(input); if (result == null || result.Branches.Count == 0) { handleNoTest(); return; } var storyTest = new StoryTest((Parse)result, (tables, counts) => handleResults(service.ParseTree <Cell, StoryTestString>(tables), counts)); if (pageName.IsSuitePage) { storyTest.ExecuteOnConfiguration(configuration); } else { storyTest.Execute(configuration); } }
public void Do(StoryTestPage page) { var elapsedTime = new ElapsedTime(); var input = page.TestContent; if (string.IsNullOrEmpty(input)) { page.WriteNonTest(); DoNoTest(); } var service = new Service.Service(configuration); Tree <Cell> result = service.Compose(new StoryTestString(input)); if (result == null || result.Branches.Count == 0) { page.WriteNonTest(); DoNoTest(); return; } var writer = new StoryTestStringWriter(service); var storyTest = new StoryTest((Parse)result, writer); if (page.Name.IsSuitePage) { storyTest.ExecuteOnConfiguration(configuration); } else { storyTest.Execute(configuration); } var pageResult = new PageResult(page.Name.Name, writer.Tables, writer.Counts, elapsedTime); page.WriteTest(pageResult); handleCounts(writer.Counts); resultWriter.WritePageResult(pageResult); }
private void ExecutePage(StoryPageName pageName, StoryTestString input, Action<StoryTestString, TestCounts> handleResults, Action handleNoTest) { var service = new Service.Service(configuration); Tree<Cell> result = service.Compose(input); if (result == null) { handleNoTest(); return; } var storyTest = new StoryTest((Parse) result.Value, (tables, counts) => handleResults(service.ParseTree<Cell, StoryTestString>(tables), counts)); if (pageName.IsSuitePage) { storyTest.ExecuteOnConfiguration(configuration); } else { storyTest.Execute(configuration); } }
public void Do(StoryTestPage page) { var elapsedTime = new ElapsedTime(); var input = page.TestContent; if (string.IsNullOrEmpty(input)) { page.WriteNonTest(); DoNoTest(); } var service = new Service.Service(configuration); Tree<Cell> result = service.Compose(new StoryTestString(input)); if (result == null || result.Branches.Count == 0) { page.WriteNonTest(); DoNoTest(); return; } var writer = new StoryTestStringWriter(service); var storyTest = new StoryTest((Parse) result, writer); if (page.Name.IsSuitePage) { storyTest.ExecuteOnConfiguration(configuration); } else { storyTest.Execute(configuration); } var pageResult = new PageResult(page.Name.Name, writer.Tables, writer.Counts, elapsedTime); page.WriteTest(pageResult); handleCounts(writer.Counts); resultWriter.WritePageResult(pageResult); }