[Test] public void NoTablesReturnsEmptyTree()
        {
            var service = new Service.Service();
            var result  = service.Compose(StoryTestSource.FromString("<b>stuff</b>"));

            Assert.AreEqual(0, result.Branches.Count);
        }
示例#2
0
 private void ProcessTestDocument(string document, StoryTestWriter writer)
 {
     try {
         var storyTest = new StoryTest(service, writer)
                         .WithInput(StoryTestSource.FromString(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);
     }
 }
        static void CheckRoundTrip(string input)
        {
            var service = new Service.Service();
            var source  = service.Compose(StoryTestSource.FromString(input));
            var result  = source.WriteBranches();

            Assert.AreEqual(input, result);
        }
示例#4
0
 public Parse PlainTest(string plainTest) {
     var writer = new StoryTestStringWriter();
     var storyTest = new StoryTest(Processor, writer)
         .WithInput(StoryTestSource.FromString("test@\n" + plainTest));
     TestClock.Instance.Elapsed = new TimeSpan();
     Clock.Instance = TestClock.Instance;
     storyTest.Execute(new Service.Service(Processor));
     Clock.Instance = new Clock();
     var resultString = writer.Tables.Substring(11);
     var parseResult = Processor.Compose(StoryTestSource.FromString(resultString));
     return (Parse)parseResult.Branches[0];
 }
        [Test] public void HtmlStringIsParsed()
        {
            var service = new Service.Service();
            var result  = service.Compose(StoryTestSource.FromString("<table><tr><td>hello</td></tr></table>"));
            var table   = ((Parse)result).Parts;

            Assert.AreEqual("<table>", table.Tag);
            var cell = table.Parts.Parts;

            Assert.AreEqual("<td>", cell.Tag);
            Assert.AreEqual("hello", cell.Body);
        }
示例#6
0
        public Parse PlainTest(string plainTest)
        {
            var writer    = new StoryTestStringWriter();
            var storyTest = new StoryTest(Processor, writer)
                            .WithInput(StoryTestSource.FromString("test@\n" + plainTest));

            storyTest.Execute(new Service.Service(Processor));
            var resultString = writer.Tables.Substring(11);
            var parseResult  = Processor.Compose(StoryTestSource.FromString(resultString));

            return((Parse)parseResult.Branches[0]);
        }
示例#7
0
        static string ProcessRequest(string request, Memory memory)
        {
            if (request == exitRequest)
            {
                return(exitReply);
            }
            var service   = new Service.Service(memory);
            var writer    = new StoryTestStringWriter();
            var storyTest = new StoryTest(service, writer).WithInput(StoryTestSource.FromString("test@\n" + request));

            storyTest.Execute();
            return(writer.Tables);
        }
示例#8
0
        public void String(string storyTestText)
        {
            var writer    = new StoryTestStringWriter();
            var storyTest = new StoryTest(processor, writer).WithInput(StoryTestSource.FromString(storyTestText));

            if (storyTest.IsExecutable)
            {
                storyTest.Execute();
                Result = writer.Tables;
            }
            else
            {
                Result = storyTestText;
            }
        }