コード例 #1
0
        public void create_example_test()
        {
            var test = new Test("some test");
            test.Section("a");
            test.Section("b");
            test.Section("c");
            Section section = new Section("Math").WithStep("MultiplyBy").WithStep("step1").WithStep("step2");
            test.Add(section);

            var structure = new StubGrammarStructure
            {
                Name = "MultiplyBy",
                Parent = new FixtureGraph("Math")
            };
            structure.ModifyExampleTest(test);

            test.Parts.Count.ShouldEqual(1);
            var theSection = test.Parts[0].ShouldBeOfType<Section>();

            theSection.Parts.Count.ShouldEqual(1);
            theSection.Parts[0].ShouldBeOfType<IStep>().GrammarKey.ShouldEqual("MultiplyBy");
        }
コード例 #2
0
 private void readFromChildNode(INode node, Test test)
 {
     if (node.IsComment())
     {
         test.AddComment(node.InnerText);
     }
     else if (node.IsTags())
     {
         test.AddTags(node.InnerText);
     }
     else
     {
         Section section = ReadSection(node);
         test.Add(section);
     }
 }
コード例 #3
0
        private void addTest(string name, Action<StepLeaf> configure)
        {
            var test = new Test(name);
            var section = new Section(typeof(SampleTableFixture).GetFixtureAlias());
            test.Add(section);
            var step = new Step("Table1");
            section.Add(step);

            var leaf = step.LeafFor("rows");
            configure(leaf);

            AddTest(name, test);
        }
コード例 #4
0
        public JavaScriptTestFile SelectorTester()
        {
            var mathTest = new Test("math");
            mathTest.Add(new Section("Math"));

            return new JavaScriptTestFile("Selector Tester")
                .TestFile("SelectorTester.js")
                .AddTest("math", mathTest)
                .Html(x =>
                {
                    FixtureLibrary library =
                        FixtureLibrary.For(o => o.AddFixturesFromAssemblyContaining<SentenceFixture>());
                    x.Add("div").Append(new TestEditorTag(library));

                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section1").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section2").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section3").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section4").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section5").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section6").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section7").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                    x.Add("Div").AddClass(GrammarConstants.EMBEDDED).Id("section8").Add("div").AddClass(
                        GrammarConstants.STEP_HOLDER).AddClass(GrammarConstants.SECTION);
                })
                .Fixtures(x => x.AddFixturesFromAssemblyContaining<SentenceFixture>());
        }
コード例 #5
0
		private Test Load( XmlDocument document )
		{
			XmlNode testNode = document.GetElementsByTagName( Constants.TAG_ROOT ).Item( 0 );

			Test test = new Test ( testNode.Attributes.GetNamedItem ( Constants.ATTR_NAME ).Value );

			XmlNode questionsNode = document.GetElementsByTagName( Constants.TAG_QUESTIONS ).Item( 0 );
			foreach ( XmlNode questionNode in questionsNode.ChildNodes )
			{
				TestQuestion question = new TestQuestion ( questionNode.Attributes.GetNamedItem (Constants.ATTR_TEXT).Value );

				foreach ( XmlNode variantNode in questionNode.ChildNodes )
				{
					question.Add( new TestQuestionVariant(
							variantNode.Attributes.GetNamedItem( Constants.ATTR_TEXT ).Value
						,	int.Parse( variantNode.Attributes.GetNamedItem( Constants.ATTR_WEIGHT ).Value )
					) );
				}

				test.Add ( question );
			}

			XmlNode conclusionsNode = document.GetElementsByTagName( Constants.TAG_CONCLUSIONS ).Item( 0 );
			test.Conclusions.AllowedLimit = int.Parse ( conclusionsNode.Attributes.GetNamedItem ( Constants.ATTR_ALLOWED ).Value );
			foreach ( XmlNode conclusionNode in conclusionsNode )
			{
				test.Conclusions.Add ( new TestConclusion (
						int.Parse( conclusionNode.Attributes.GetNamedItem( Constants.ATTR_FROM ).Value )
					,	int.Parse( conclusionNode.Attributes.GetNamedItem( Constants.ATTR_TO ).Value )
					,	conclusionNode.InnerText
				) );
			}

			return test;
		}