Ejemplo n.º 1
0
        void SetUpSUT(string memberName)
        {
            this.memberName = memberName;
            testStatus      = new TestStatus();
            processor       = new Mock <CellProcessor>();
            execute         = new ExecuteDefault {
                Processor = processor.Object
            };

            target = new TypedValue("target");
            result = new TypedValue("result");

            targetCell = new CellTreeLeaf("stuff");

            processor
            .Setup(p => p.Parse(typeof(MemberName), It.IsAny <TypedValue>(), It.Is <CellTreeLeaf>(c => c.Text == memberName)))
            .Returns(new TypedValue(new MemberName(memberName)));
            processor
            .Setup(p => p.Invoke(target, "member", It.Is <Tree <Cell> >(c => c.Branches.Count == 0)))
            .Returns(result);
            processor
            .Setup(p => p.Invoke(It.Is <TypedValue>(v => v.ValueString == "target"), "procedure", It.IsAny <Tree <Cell> >()))
            .Returns((TypedValue t, string s, Tree <Cell> c) => {
                testStatus.Counts.AddCount(TestStatus.Right);
                testStatus.LastAction = "blah blah";
                return(result);
            });
            processor.Setup(p => p.TestStatus).Returns(testStatus);
        }
Ejemplo n.º 2
0
        void SetupSUT(string html)
        {
            procedure = new Procedure("procedure", Parse.ParseFrom(html));

            result  = new TypedValue("result");
            target  = new TypedValue("target");
            fixture = new TypedValue("fixture");

            testStatus = new TestStatus();

            processor = new Mock <CellProcessor>();
            runtime   = new RuntimeProcedure {
                Processor = processor.Object
            };

            processor.Setup(p => p.TestStatus).Returns(testStatus);
            processor.Setup(p => p.Contains(It.Is <Procedure>(v => v.Id == "member"))).Returns(false);
            processor.Setup(p => p.Contains(It.Is <Procedure>(v => v.Id == "procedure"))).Returns(true);
            processor.Setup(p => p.Load(It.Is <Procedure>(v => v.Id == "procedure"))).Returns(procedure);

            processor.Setup(p => p.Parse(typeof(Interpreter), target, It.Is <Tree <Cell> >(c => IsDoFixture(c))))
            .Returns(fixture);

            processor.Setup(p => p.Execute(fixture, It.Is <Tree <Cell> >(t => IsTablesWithVerb(t))))
            .Returns((TypedValue f, Tree <Cell> t) => {
                t.Branches[0].Branches[0].Branches[0].Value.SetAttribute(CellAttribute.Label, "stuff");
                testStatus.PopReturn();
                testStatus.PushReturn(result);
                return(TypedValue.Void);
            });

            processor.Setup(p => p.Parse(typeof(StoryTestString), It.IsAny <TypedValue>(),
                                         It.Is <Tree <Cell> >(t => IsTableWithVerb(t))))
            .Returns(new TypedValue("procedure log"));
        }
Ejemplo n.º 3
0
 public bool FinalCheck(TestStatus testStatus) {
     if (myColumnsUsed == null) return true;
     for (int column = 0; column < myHeaderRow.Branches.Count; column++) {
         if (myColumnsUsed[column]) continue;
         testStatus.MarkException(myHeaderRow.Branches[column].Value,
                                  new FitFailureException(String.Format("Column '{0}' not used.", myHeaderRow.Branches[column].Value.Text)));
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
 public bool FinalCheck(TestStatus testStatus)
 {
     if (myColumnsUsed == null) return true;
     for (int column = 0; column < myHeaderRow.Parts.Size; column++) {
         if (myColumnsUsed[column]) continue;
         testStatus.MarkException(myHeaderRow.Parts.At(column),
                                  new FitFailureException(String.Format("Column '{0}' not used.", myHeaderRow.Parts.At(column).Text)));
         return false;
     }
     return true;
 }
Ejemplo n.º 5
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); 
			}
		}
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
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);
     }
 }
Ejemplo n.º 8
0
        void SetupSUT(string html)
        {
            procedure = new Procedure("procedure", Parse.ParseFrom(html));

            result = new TypedValue("result");
            target = new TypedValue("target");

            fixture = new Mock <FlowInterpreter>();

            flow = new Mock <InterpretTableFlow>();
            flow.Setup(f => f.DoTableFlow(It.IsAny <CellProcessor>(), fixture.Object, It.Is <Tree <Cell> >(t => IsTablesWithVerb(t))))
            .Callback <CellProcessor, FlowInterpreter, Tree <Cell> >((p, f, t) => {
                t.Branches[0].Branches[0].Value.SetAttribute(CellAttribute.Label, "stuff");
                testStatus.PopReturn();
                testStatus.PushReturn(result);
            });

            testStatus = new TestStatus();

            processor = new Mock <CellProcessor>();
            invoke    = new InvokeProcedure {
                Processor = processor.Object
            };

            processor.Setup(p => p.TestStatus).Returns(testStatus);
            processor.Setup(p => p.Contains(It.Is <Procedure>(v => v.Id == "member"))).Returns(false);
            processor.Setup(p => p.Contains(It.Is <Procedure>(v => v.Id == "procedure"))).Returns(true);
            processor.Setup(p => p.Load(It.Is <Procedure>(v => v.Id == "procedure"))).Returns(procedure);

            processor.Setup(p => p.Parse(typeof(Interpreter), target, It.Is <Tree <Cell> >(c => IsDoFixture(c))))
            .Returns(new TypedValue(fixture.Object));

            processor.Setup(p => p.Parse(typeof(StoryTestString), It.IsAny <TypedValue>(),
                                         It.Is <Tree <Cell> >(t => IsTableWithVerb(t))))
            .Returns(new TypedValue("procedure log"));
        }
        void SetUpSUT(string memberName)
        {
            this.memberName = memberName;
            testStatus = new TestStatus();
            processor = new Mock<CellProcessor>();
            invoke = new InvokeOperationDefault {Processor = processor.Object};
            check = new CheckOperationDefault {Processor = processor.Object};

            target = new TypedValue("target");
            result = new TypedValue("result");

            targetCell = new CellTreeLeaf("stuff");

            processor
                .Setup(p => p.Parse(typeof (MemberName), It.IsAny<TypedValue>(), It.Is<CellTreeLeaf>(c => c.Text == memberName)))
                .Returns(new TypedValue(new MemberName(memberName)));
            processor
                .Setup(p => p.Invoke(target, "member", It.Is<Tree<Cell>>(c => c.Branches.Count == 0)))
                .Returns(result);
            processor
                .Setup(p => p.Invoke(It.Is<TypedValue>(v => v.ValueString == "target"), "procedure", It.IsAny<Tree<Cell>>()))
                .Returns((TypedValue t, string s, Tree<Cell> c) => {
                    testStatus.Counts.AddCount(TestStatus.Right);
                    testStatus.LastAction = "blah blah";
                    return result;
                });
            processor.Setup(p => p.Compare(It.IsAny<TypedValue>(), It.IsAny<Tree<Cell>>())).Returns(true);
            processor.Setup(p => p.TestStatus).Returns(testStatus);
        }
Ejemplo n.º 10
0
 public Define()
 {
     TestStatus = new TestStatus();
 }
Ejemplo n.º 11
0
        private void SetupSUT(string html)
        {
            procedure = new Procedure("procedure", new HtmlParser().Parse(html));

            result = new TypedValue("result");
            target = new TypedValue("target");
            fixture = new TypedValue("fixture");

            testStatus = new TestStatus();

            processor = new Mock<CellProcessor>();
            runtime = new RuntimeProcedure {Processor = processor.Object};

            processor.Setup(p => p.TestStatus).Returns(testStatus);
            processor.Setup(p => p.Contains(It.Is<Procedure>(v => v.Id == "member"))).Returns(false);
            processor.Setup(p => p.Contains(It.Is<Procedure>(v => v.Id == "procedure"))).Returns(true);
            processor.Setup(p => p.Load(It.Is<Procedure>(v => v.Id == "procedure"))).Returns(procedure);

            processor.Setup(p => p.Parse(typeof (Interpreter), target, It.Is<Tree<Cell>>(c => IsDoFixture(c))))
                .Returns(fixture);

            processor.Setup(p => p.Execute(fixture, It.Is<Tree<Cell>>(t => IsTablesWithVerb(t))))
                .Returns((TypedValue f, Tree<Cell> t) => {
                    t.Branches[0].Branches[0].Branches[0].Value.SetAttribute("some", "stuff");
                    testStatus.PopReturn();
                    testStatus.PushReturn(result);
                    return TypedValue.Void;
                });

            processor.Setup(p => p.Parse(typeof (StoryTestString), It.IsAny<TypedValue>(),
                                         It.Is<Tree<Cell>>(t => IsTableWithVerb(t))))
                .Returns(new TypedValue("procedure log"));
        }
 public bool FinalCheck(TestStatus testStatus)
 {
     return true;
 }
Ejemplo n.º 13
0
        void SetupSUT(string html)
        {
            procedure = new Procedure("procedure", Parse.ParseFrom(html));

            result = new TypedValue("result");
            target = new TypedValue("target");

            fixture = new Mock<FlowInterpreter>();
            fixture.Setup(f => f.InterpretFlow(It.Is<Tree<Cell>>(t => IsTablesWithVerb(t))))
                .Callback<Tree<Cell>>(t =>  {
                    t.Branches[0].Branches[0].Value.SetAttribute(CellAttribute.Label, "stuff");
                    testStatus.PopReturn();
                    testStatus.PushReturn(result);
                });

            testStatus = new TestStatus();

            processor = new Mock<CellProcessor>();
            invoke = new InvokeProcedure {Processor = processor.Object};

            processor.Setup(p => p.TestStatus).Returns(testStatus);
            processor.Setup(p => p.Contains(It.Is<Procedure>(v => v.Id == "member"))).Returns(false);
            processor.Setup(p => p.Contains(It.Is<Procedure>(v => v.Id == "procedure"))).Returns(true);
            processor.Setup(p => p.Load(It.Is<Procedure>(v => v.Id == "procedure"))).Returns(procedure);

            processor.Setup(p => p.Parse(typeof (Interpreter), target, It.Is<Tree<Cell>>(c => IsDoFixture(c))))
                .Returns(new TypedValue(fixture.Object));

            processor.Setup(p => p.Parse(typeof (StoryTestString), It.IsAny<TypedValue>(),
                                         It.Is<Tree<Cell>>(t => IsTableWithVerb(t))))
                .Returns(new TypedValue("procedure log"));
        }
Ejemplo n.º 14
0
 public ConfigureFixture()
 {
     TestStatus = new TestStatus();
 }
Ejemplo n.º 15
0
 public FixtureFixture()
 {
     ourEmbeddedCounts = new TestStatus();
 }