Example #1
0
 public CellBase(CellBase other)
 {
     if (other.attributes != null)
     {
         attributes = new Dictionary <CellAttribute, string>(other.attributes);
     }
     Text = other.Text;
 }
Example #2
0
 public CellBase(CellBase other)
 {
     if (other != null)
     {
         attributes = new Dictionary <CellAttribute, CellAttributeValue>(other.attributes);
         Text       = other.Text;
     }
     else
     {
         Text = string.Empty;
     }
 }
Example #3
0
 public Tree<CellBase> Parse(string input) {
     var alternationParser = new AlternationParser();
     var cells = new ListParser("td", alternationParser, false);
     var rows = new ListParser("tr", cells, true);
     var tables = new ListParser("table", rows, true);
     var items = new ListParser("li", alternationParser, false);
     var lists = new ListParser("ul", items, true);
     alternationParser.ChildParsers = new [] {tables, lists};
     var root = new CellBase(string.Empty, "div");
     var result = new TreeList<CellBase>(root);
     foreach (Tree<CellBase> branch in tables.Parse(new LexicalAnalyzer(input))) result.AddBranch(branch);
     return result;
 }
Example #4
0
        private void ProcessTestDocument(string document, StoryTestWriter writer) {
			try {
			    var storyTest = new StoryTest(service, writer)
                    .WithInput(document)
                    .OnAbandonSuite(() => { suiteIsAbandoned = true; });
			    reporter.WriteLine(storyTest.Leader);
			    if (suiteSetupIdentifier.IsStartOf(storyTest.Leader) || IMaybeProcessingSuiteSetup)
                    storyTest.Execute();
                else
                    storyTest.Execute(new Service.Service(service));
			}
			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); 
			}
		}
Example #5
0
 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);
     }
 }
Example #6
0
 public CellBase(CellBase other)
 {
     if (other.attributes != null) attributes = new Dictionary<CellAttribute, string>(other.attributes);
     Text = other.Text;
 }
Example #7
0
 static TreeList<CellBase> MakeRootNode()
 {
     var sourceNode = new CellBase("text");
     sourceNode.SetAttribute(CellAttribute.EndTag, "</tag>");
     sourceNode.SetAttribute(CellAttribute.Leader, "leader");
     sourceNode.SetAttribute(CellAttribute.StartTag, "<tag stuff>");
     sourceNode.SetAttribute(CellAttribute.Trailer, "trailer");
     return new TreeList<CellBase>(sourceNode);
 }
Example #8
0
 static void AddBranch(TreeList<CellBase> source, string body)
 {
     var branchNode = new CellBase("text");
     branchNode.SetAttribute(CellAttribute.Body, body);
     branchNode.SetAttribute(CellAttribute.EndTag, "</leaftag>");
     branchNode.SetAttribute(CellAttribute.StartTag, "<leaftag>");
     source.AddBranchValue(branchNode);
 }
Example #9
0
 [Test] public void LoggerReceivesEndCellEvent() {
     logging.Add(new TestLogger());
     logging.Start();
     var cell = new CellBase("stuff");
     logging.BeginCell(cell);
     logging.EndCell(cell);
     Assert.AreEqual(null, TestLogger.ActiveCell);
 }
Example #10
0
 public CellBase(CellBase other) {
     attributes = new Dictionary<CellAttribute, CellAttributeValue>(other.attributes);
     Text = other.Text;
 }
 [Test] public void FoldedWithoutExtraTextFormatsBody() {
     var cell = new CellBase(string.Empty);
     cell.SetAttribute(CellAttribute.Body, "stuff");
     cell.SetAttribute(CellAttribute.Folded, string.Empty);
     Assert.AreEqual(FormatFolded("stuff"), ParseStoryTestString.Body(cell));
 }
 [Test] public void FoldedWithExtraTextIsFormatted() {
     var cell = new CellBase(string.Empty);
     cell.SetAttribute(CellAttribute.Body, string.Empty);
     cell.SetAttribute(CellAttribute.Folded, "more");
     Assert.AreEqual(FormatFolded("more"), ParseStoryTestString.Body(cell));
 }
Example #13
0
 public CellBase(CellBase other)
 {
     attributes = new Dictionary <CellAttribute, CellAttributeValue>(other.attributes);
     Text       = other.Text;
 }