示例#1
0
        public void XmlNullError()
        {
            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback cb = new TestCallback();
            tester.TestOnServerResponse(null, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.INVALID_XML_ERROR);
            Assert.AreEqual(cb.info.msg, "Invalid server response");
        }
示例#2
0
        public void XmlNotRoarError()
        {
            string xml = "<nasa>space shuttle</nasa>";
            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback cb = new TestCallback();
            tester.TestOnServerResponse(xml, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.INVALID_XML_ERROR);
            Assert.AreEqual(cb.info.msg, "Incorrect XML response");
        }
示例#3
0
        public void XmlNullError()
        {
            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback          cb     = new TestCallback();

            tester.TestOnServerResponse(null, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.INVALID_XML_ERROR);
            Assert.AreEqual(cb.info.msg, "Invalid server response");
        }
示例#4
0
        public void XmlMalformedError()
        {
            string xml = "<sonda> bak </def>";
            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback cb = new TestCallback();
            tester.TestOnServerResponse(xml, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.INVALID_XML_ERROR);
            Assert.AreEqual(cb.info.msg.Substring(0, 66), "System.Xml.XmlException: 'sonda' is expected  Line 1, position 16.");
        }
示例#5
0
        public void XmlMalformedError()
        {
            string xml = "<sonda> bak </def>";
            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback          cb     = new TestCallback();

            tester.TestOnServerResponse(xml, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.INVALID_XML_ERROR);
            Assert.AreEqual(cb.info.msg.Substring(0, 66), "System.Xml.XmlException: 'sonda' is expected  Line 1, position 16.");
        }
示例#6
0
        public void XmlNotRoarError()
        {
            string xml = "<nasa>space shuttle</nasa>";
            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback          cb     = new TestCallback();

            tester.TestOnServerResponse(xml, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.INVALID_XML_ERROR);
            Assert.AreEqual(cb.info.msg, "Incorrect XML response");
        }
示例#7
0
        public void XmlIoError()
        {
            string xml =
            @"<roar>
                <io>
                    <retry status=""ok"">Please try again in a few moments.</retry>
                </io>
            </roar>";

            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback cb = new TestCallback();
            tester.TestOnServerResponse(xml, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.IO_ERROR);
            Assert.AreEqual(cb.info.msg, "Please try again in a few moments.");
        }
示例#8
0
        public void XmlIoError()
        {
            string xml =
                @"<roar>
				<io>
					<retry status=""ok"">Please try again in a few moments.</retry>
				</io>
			</roar>"            ;

            OnRequestSenderTester tester = new OnRequestSenderTester();
            TestCallback          cb     = new TestCallback();

            tester.TestOnServerResponse(xml, "user/login", cb);

            Assert.AreEqual(cb.info.code, IWebAPI.IO_ERROR);
            Assert.AreEqual(cb.info.msg, "Please try again in a few moments.");
        }
        private static bool PerformTests(string listName, string targetInputAttribute, string targetOutputAttribute, TestCallback callback)
        {
            (bool success, XmlNode nodeList)testMatch = XmlManager.GetFirstLevelChild(listName, ref testDocument, "name");

            if (testMatch.nodeList.Attributes["run"].Value == "false")
            {
                return(true);
            }

            bool passed = true;

            if (testMatch.success)
            {
                foreach (XmlNode node in testMatch.nodeList.ChildNodes)
                {
                    bool success = callback(
                        node.Attributes[targetInputAttribute].Value,
                        node.Attributes[targetOutputAttribute].Value,
                        node.Attributes["debug"].Value == "true"
                        );

                    passed = success ? passed : false;
                }
            }

            if (!passed)
            {
                GUIController.LogOutput($"Test {listName} FAILED");
            }

            return(passed);
        }