예제 #1
0
 public void SetUp()
 {
     TestUtils.InitAssembliesAndNamespaces();
     var builder = new TestBuilder();
     builder.Append("<table>");
     builder.Append("<tr><td colspan='5'>ExampleTableFixture</td></tr>");
     builder.Append("<tr><td>0,0</td><td>0,1</td><td>0,2</td><td>37</td><td></td></tr>");
     builder.Append("</table>");
     myStoryTest = new StoryTest(builder.Parse, SimpleWriter);
     myStoryTest.Execute(new TypeDictionary());
 }
예제 #2
0
 public void TestEmptyHeaderCell()
 {
     TestUtils.InitAssembliesAndNamespaces();
     var builder = new TestBuilder();
     builder.Append("<table>");
     builder.Append("<tr><td colspan=\"2\">string fixture</td></tr>");
     builder.Append("<tr><td>field</td><td></td></tr>");
     builder.Append("<tr><td>some value</td><td>this is a comment</td></tr>");
     builder.Append("</table>");
     var table = builder.Parse;
     RunTest(table);
     TestUtils.CheckCounts(resultCounts, 0, 0, 0, 0);
 }
예제 #3
0
 static Parse BuildTable(IEnumerable<string> values)
 {
     var builder = new TestBuilder();
     builder.Append("<table>");
     builder.Append("<tr><td>BusinessObjectRowFixture</td></tr>");
     builder.Append("<tr><td>GetFirstString</td></tr>");
     foreach (string value in values)
     {
         builder.Append("<tr><td>" + value + "</td></tr>");
     }
     builder.Append("</table>");
     return builder.Parse;
 }
예제 #4
0
		public void SetUp()
		{
			TestUtils.InitAssembliesAndNamespaces();
			var builder = new TestBuilder();
			builder.Append("<table>");
			builder.Append("<tr><td colspan='5'>ExampleTableFixture</td></tr>");
			builder.Append("<tr><td>0,0</td><td>0,1</td><td>0,2</td><td>37</td><td></td></tr>");
			builder.Append("</table>");
		    table = builder.Parse.Parts;
            fixture = new ExampleTableFixture {Processor = new Service.Service()};
		    fixture.DoTable(table);
		    resultCounts = fixture.TestStatus.Counts;
		}
예제 #5
0
 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..")));
 }
예제 #6
0
 public void TestRemoveHandler()
 {
     Configuration configuration = TestUtils.InitAssembliesAndNamespaces();
     new Service.Service(configuration).AddOperator(new CompareSubstring());
     var builder = new TestBuilder();
     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 = builder.MakeStoryTest();
     test.ExecuteOnConfiguration(configuration);
     Assert.IsFalse(new Service.Service(configuration).Compare(new TypedValue("abc"), TestUtils.CreateCell("..b..")));
 }
예제 #7
0
        public void TestBlankCell()
        {
            var builder = new TestBuilder();
            builder.Append("<table>");
            builder.Append("<tr><td colspan=\"6\">string fixture</td></tr>");
            builder.Append("<tr><td>field</td><td>field?</td><td>property</td><td>property?</td><td>set</td><td>get?</td></tr>");
            builder.Append("<tr><td>blank</td><td>blank</td><td>blank</td><td>blank</td><td>blank</td><td>blank</td></tr>");
            builder.Append("</table>");

            var parse = builder.Parse;

            TestUtils.InitAssembliesAndNamespaces();
            RunTest(parse);
            TestUtils.CheckCounts(resultCounts, 3, 0, 0, 0);
        }
예제 #8
0
        public void TestNullCell()
        {
            var builder = new TestBuilder();
            builder.Append("<table>");
            builder.Append("<tr><td colspan=\"2\">string fixture</td></tr>");
            builder.Append("<tr><td>Field</td><td>Field?</td></tr>");
            builder.Append("<tr><td></td><td>null</td></tr>");
            builder.Append("</table>");

            var parse = builder.Parse;

            TestUtils.InitAssembliesAndNamespaces();
            RunTest(new StringFixture(), parse);
            TestUtils.CheckCounts(resultCounts, 1, 0, 0, 0);
        }
예제 #9
0
 public void TestExecuteAtEnd()
 {
     TestUtils.InitAssembliesAndNamespaces();
     var builder = new TestBuilder();
     builder.Append("<table>");
     builder.Append("<tr><td colspan=\"2\">ExecuteTestFixture</td></tr>");
     builder.Append("<tr><td>Property</td><td>Property</td></tr>");
     builder.Append("<tr><td>first call</td><td>second call</td></tr>");
     builder.Append("</table>");
     var table = builder.Parse.Parts;
     var testFixture = new ExecuteTestFixture { Processor = new Service.Service()};
     testFixture.DoTable(table);
     Assert.AreEqual(3, testFixture.Values.Count);
     Assert.AreEqual("first call", testFixture.Values[0]);
     Assert.AreEqual("second call", testFixture.Values[1]);
     Assert.AreEqual("Execute()", testFixture.Values[2]);
 }
예제 #10
0
 public void TestExecuteDoesNotCauseMethodsToGetCalledThrice()
 {
     TestUtils.InitAssembliesAndNamespaces();
     var builder = new TestBuilder();
     builder.Append("<table>");
     builder.Append("<tr><td colspan=\"2\">ExecuteTestFixture</td></tr>");
     builder.Append("<tr><td>Method()</td></tr>");
     builder.Append("<tr><td>1</td></tr>");
     builder.Append("<tr><td>2</td></tr>");
     builder.Append("</table>");
     var table = builder.Parse.Parts;
     var testFixture = new ExecuteTestFixture { Processor = new Service.Service()};
     testFixture.DoTable(table);
     Assert.AreEqual(4, testFixture.Values.Count);
     Assert.AreEqual("Execute()", testFixture.Values[0]);
     Assert.AreEqual("Method()", testFixture.Values[1]);
     Assert.AreEqual("Execute()", testFixture.Values[2]);
     Assert.AreEqual("Method()", testFixture.Values[3]);
     TestUtils.VerifyCounts(testFixture, 2, 0, 0, 0);
 }
예제 #11
0
        public void TestExecuteDoesNotCauseMethodsToGetCalledThrice()
        {
            TestUtils.InitAssembliesAndNamespaces();
            var builder = new TestBuilder();

            builder.Append("<table>");
            builder.Append("<tr><td colspan=\"2\">ExecuteTestFixture</td></tr>");
            builder.Append("<tr><td>Method()</td></tr>");
            builder.Append("<tr><td>1</td></tr>");
            builder.Append("<tr><td>2</td></tr>");
            builder.Append("</table>");
            var table       = builder.Parse.Parts;
            var testFixture = new ExecuteTestFixture {
                Processor = new Service.Service()
            };

            testFixture.DoTable(table);
            Assert.AreEqual(4, testFixture.Values.Count);
            Assert.AreEqual("Execute()", testFixture.Values[0]);
            Assert.AreEqual("Method()", testFixture.Values[1]);
            Assert.AreEqual("Execute()", testFixture.Values[2]);
            Assert.AreEqual("Method()", testFixture.Values[3]);
            TestUtils.VerifyCounts(testFixture, 2, 0, 0, 0);
        }
예제 #12
0
 public void TestArrayOfStrings()
 {
     ArrayOfStringsRowFixture.items.Clear();
     const string setUpTableHtml = "<table>" +
                                   "<tr><td colspan=\"3\">ArrayOfStringsFixture</td></tr>" +
                                   "<tr><td>field</td><td>save!</td></tr>" +
                                   "<tr><td>a,b,c</td><td></td></tr>" +
                                   "</table>";
     const string tableHtml = "<table>" +
                              "<tr><td colspan=\"3\">ArrayOfStringsRowFixture</td></tr>" +
                              "<tr><td>field</td></tr>" +
                              "<tr><td>a,b,c</td></tr>" +
                              "</table>";
     var testTable = new TestBuilder(tableHtml).Parse;
     RunTest(new ArrayOfStringsFixture(), new TestBuilder(setUpTableHtml).Parse);
     RunTest(new ArrayOfStringsRowFixture(), testTable);
     Assert.AreEqual(TestStatus.Right,
                     testTable.Parts.Parts.More.More.Parts.Value.GetAttribute(CellAttribute.Status));
 }
예제 #13
0
 public void TestCorrectFormatForMissing()
 {
     PeopleLoaderFixture.people.Clear();
     const string loaderFixtureHtml = "<table>" +
                                      "<tr><td colspan=\"3\">people loader fixture</td></tr>" +
                                      "<tr><td>id</td><td>first name</td><td>last name</td></tr>" +
                                      "<tr><td>1</td><td>null</td><td>Jones</td></tr>" +
                                      "<tr><td>2</td><td>Phil</td><td>blank</td></tr>" +
                                      "</table>";
     const string inspectorFixtureHtml = "<table>" +
                                         "<tr><td colspan=\"3\">people row fixture</td></tr>" +
                                         "<tr><td>id</td><td>first name</td><td>last name</td></tr>" +
                                         "<tr><td>7</td><td>nullest</td><td>Jonesey</td></tr>" +
                                         "<tr><td>2</td><td>Phil</td><td>blank</td></tr>" +
                                         "</table>";
     var testTable = new TestBuilder(inspectorFixtureHtml).Parse;
     RunTest(new PeopleLoaderFixture(), new TestBuilder(loaderFixtureHtml).Parse);
     RunTest(new PeopleRowFixture(), testTable);
     Assert.AreEqual(
         "<tr><td class=\"fail\">7 <span class=\"fit_label\">missing</span></td><td>nullest</td><td>Jonesey</td></tr>" +
         "<tr><td class=\"pass\">2</td><td class=\"pass\">Phil</td><td class=\"pass\">blank</td></tr>" +
         "\n<tr>\n<td class=\"fail\"><span class=\"fit_grey\">1</span> <span class=\"fit_label\">surplus</span></td>\n<td><span class=\"fit_grey\">null</span></td>\n<td><span class=\"fit_grey\">Jones</span></td></tr>",
         testTable.Parts.Parts.More.More.ToString());
 }
예제 #14
0
 public void TestStartsWithHandlerInSecondColumn()
 {
     processor.AddOperator(typeof(CompareStartsWith).FullName);
     var builder = new TestBuilder();
     builder.Append("<table>");
     builder.Append("<tr><td>people row fixture</td></tr>");
     builder.Append("<tr><td>first name</td><td>last name</td></tr>");
     builder.Append("<tr><td>Nigel</td><td>Tuf..</td></tr>");
     builder.Append("</table>");
     PeopleLoaderFixture.people.Clear();
     PeopleLoaderFixture.people.Add(new Person("Nigel", "Tufnel"));
     var tables = builder.Parse;
     RunTest(new PeopleRowFixture(), tables);
     Assert.IsTrue(tables.ToString().IndexOf("Tuf..") > -1);
     Assert.IsFalse(tables.ToString().IndexOf("Tufnel") > -1);
     TestUtils.CheckCounts(resultCounts, 2, 0, 0, 0);
 }
예제 #15
0
        public void TestMissing()
        {
            TestUtils.InitAssembliesAndNamespaces();
            var builder = new TestBuilder();
            builder.Append("<table>");
            builder.Append("<tr><td>BusinessObjectRowFixture</td></tr>");
            builder.Append("<tr><td>GetFirstString</td></tr>");
            builder.Append("<tr><td>number1</td></tr>");
            builder.Append("<tr><td>number2</td></tr>");
            builder.Append("<tr><td>number3</td></tr>");
            builder.Append("</table>");
            var parse = builder.Parse;

            BusinessObjectRowFixture.objects = new object[]
                                               {
                                                   new BusinessObject(new[] {"number1"}),
                                               };

            RunTest(new BusinessObjectRowFixture(), parse);
            Assert.IsTrue(parse.ToString().IndexOf("number1") > 0);
            Assert.IsTrue(parse.ToString().IndexOf("number2") > 0);
            Assert.IsTrue(parse.ToString().IndexOf("number3") > 0);
            TestUtils.CheckCounts(resultCounts, 1, 2, 0, 0);
        }
예제 #16
0
 public void UsesDynamicTarget()
 {
     TestUtils.InitAssembliesAndNamespaces();
     var builder = new TestBuilder();
     builder.Append("<table>");
     builder.Append("<tr><td>dynamic target fixture</td></tr>");
     builder.Append("<tr><td>count?</td></tr>");
     builder.Append("<tr><td>0</td></tr>");
     builder.Append("<tr><td>1</td></tr>");
     builder.Append("</table>");
     var table = builder.Parse.Parts;
     var testFixture = new DynamicTargetFixture{ Processor = new Service.Service()};
     testFixture.DoTable(table);
     TestUtils.VerifyCounts(testFixture, 2, 0, 0, 0);
 }
예제 #17
0
 public void TestArrayOfStrings()
 {
     ArrayOfStringsRowFixture.items.Clear();
     const string setUpTableHtml = "<table>" +
                                   "<tr><td colspan=\"3\">ArrayOfStringsFixture</td></tr>" +
                                   "<tr><td>field</td><td>save!</td></tr>" +
                                   "<tr><td>a,b,c</td><td></td></tr>" +
                                   "</table>";
     const string processedSetUpTableHtml = "<table>" +
                                            "<tr><td colspan=\"3\">ArrayOfStringsFixture</td></tr>" +
                                            "<tr><td>field</td><td>save!</td></tr>" +
                                            "<tr><td>a,b,c</td><td><span class=\"fit_grey\"> null</span></td></tr>" +
                                            "</table>";
     const string tableHtml = "<table>" +
                              "<tr><td colspan=\"3\">ArrayOfStringsRowFixture</td></tr>" +
                              "<tr><td>field</td></tr>" +
                              "<tr><td>a,b,c</td></tr>" +
                              "</table>";
     const string expected = "<table>" +
                             "<tr><td colspan=\"3\">ArrayOfStringsRowFixture</td></tr>" +
                             "<tr><td>field</td></tr>" +
                             "<tr><td class=\"pass\">a,b,c</td></tr>" +
                             "</table>";
     var tables = new TestBuilder(setUpTableHtml + tableHtml).Parse;
     RunTest(tables);
     Assert.AreEqual(processedSetUpTableHtml + expected, testResult);
 }