Beispiel #1
0
        public void FitNessePageLoadTableFromPageNegativeTestCases(string tableName, string page)
        {
            var fitnessePage = new FitNessePageMock(page);
            var dict         = fitnessePage.LoadTableFromPage("tableName", tableName);

            Assert.AreEqual(dict.Count, 0, tableName);
        }
Beispiel #2
0
        public void FitNessePageDeleteTest()
        {
            var fitnessePage = new FitNessePageMock(null);

            fitnessePage.DeletePage("PageName");
            Assert.AreEqual(DeletePageRequest, fitnessePage.UsedUri);
        }
Beispiel #3
0
        public void FitNessePageLoadTableFromPageTestsWithOneResult(string testCase, string inputPage)
        {
            var fitnessePage = new FitNessePageMock(inputPage);
            var dict         = fitnessePage.LoadTableFromPage("Main", testCase);

            Assert.AreEqual(1, dict.Count, "Entry Count for testcase " + testCase);
            Assert.AreEqual("value", dict["key"], "Entry for testcase " + testCase);
        }
Beispiel #4
0
        public void FitNessePageAddTest()
        {
            // The first entry ensures that characters that need to be escaped are handled correctly
            // the hash is a notorious one - if you leave that unescaped, FitNesse will ignore the rest of the page.
            var lines        = new[] { "#escape characters<grin>&", "!|Dictionary|TableName|", "|key1|value1|" };
            var fitnessePage = new FitNessePageMock(null);

            _addPageMethod.Invoke(fitnessePage, new object[] { "PageName", lines });
            const string expected = AddChildPartialRequest + "#escape characters<grin>&\n!|Dictionary|TableName|\n|key1|value1|\n\f";

            Assert.AreEqual(expected, fitnessePage.UsedUri);
        }
Beispiel #5
0
        public void FitNessePageSavePageTest()
        {
            const string pageContent  = "\nq\n|Dictionary|TableName|\n|Key|Value|\n|key1|value1|\nq\n";
            var          fitnessePage = new FitNessePageMock(pageContent);

            fitnessePage.LoadTableFromPage("TableName", "PageName");
            _savePageMethod.Invoke(fitnessePage, new object[] { "PageName" });
            const string expected = PageDataRequest + DeletePageRequest + AddChildPartialRequest +
                                    "\nq\n|Dictionary|TableName|\n|Key|Value|\n|key1|value1|\nq\n" + UriSeparator;

            Assert.AreEqual(expected, fitnessePage.UsedUri);
        }
Beispiel #6
0
        public void FitNessePageDeleteTableFromPageTest()
        {
            const string pageContent  = "\nq\n|Dictionary|TableName|\n|key|value|\n|key1|value1|\nq\n";
            var          fitnessePage = new FitNessePageMock(pageContent);

            Assert.IsTrue(fitnessePage.DeleteTableFromPage("TableName", "PageName"));
            const string expected = PageDataRequest + DeletePageRequest + AddChildPartialRequest + "\nq\nq\n" + UriSeparator;

            Assert.AreEqual(expected, fitnessePage.UsedUri);
            Assert.IsFalse(fitnessePage.DeleteTableFromPage("WrongTableName", "PageName"),
                           "Non-existing table returns false");
        }
Beispiel #7
0
        public void FitNessePageInsertTableAtTests(string testCase, string inputPage, int lineIndex, string expectedResult)
        {
            var dict = new Dictionary <string, string> {
                { "key5", "value5" }, { "key6", "value6" }
            };
            var fitnessePage = new FitNessePageMock(inputPage);

            fitnessePage.LoadTableFromPage("TableName", "PageName");
            _insertTableAtMethod.Invoke(fitnessePage, new object[] { "NewTableName", dict, lineIndex });
            _savePageMethod.Invoke(fitnessePage, new object[] { "PageName" });
            var expected = PageDataRequest + DeletePageRequest + AddChildPartialRequest + expectedResult;

            Assert.AreEqual(expected, fitnessePage.UsedUri, "Testcase " + testCase);
        }
Beispiel #8
0
        public void FitNessePageSaveTableToPageTests(string testCase, string inputPage, string resultPage)
        {
            var dict = new Dictionary <string, string> {
                { "key2", "value2" }, { "key3", "value3" }
            };
            var fitnessePage = new FitNessePageMock(inputPage);

            fitnessePage.SaveTableToPage("TableName", "PageName", dict);
            var expected = AddChildPartialRequest + resultPage;

            // we're only interested in the last result
            var actual = fitnessePage.UsedUri.Split(new[] { UriSeparator }, StringSplitOptions.RemoveEmptyEntries).Last();

            Assert.AreEqual(expected, actual, "Test case " + testCase);
        }
Beispiel #9
0
        public void FitNessePageDeleteTableFromEmptyPageTest()
        {
            var fitnessePage = new FitNessePageMock(null);

            Assert.IsFalse(fitnessePage.DeleteTableFromPage("TableName", "PageName"));
        }