Ejemplo n.º 1
0
        public void TestSingleConnection_Success()
        {
            PublicConnection.Authentication.Authenticate();
            PublicConnection.URLParameters = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition }
            };

            PublicConnection.ServerURL   = PublicAPIConfig.ServerURL;
            PublicConnection.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            PublicConnection.RelativeURL = API_URL;

            XmlHandler handler = PublicConnection.SendRequest() as XmlHandler;

            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            XElement xmlCode = handler.XML.Descendants("Code").First();

            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);

            PublicConnection.ServerURL   = PublicAPIConfig.ServerURL;
            PublicConnection.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            PublicConnection.RelativeURL = API_URL;

            handler = PublicConnection.SendRequest() as XmlHandler;

            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            xmlCode = handler.XML.Descendants("Code").First();
            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);
        }
Ejemplo n.º 2
0
        public void TestMultipleConnections_Success()
        {
            // TestBase Connection
            PublicConnection.Authentication.Authenticate();
            PublicConnection.URLParameters = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition }
            };

            PublicConnection.ServerURL   = PublicAPIConfig.ServerURL;
            PublicConnection.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            PublicConnection.RelativeURL = API_URL;

            XmlHandler handler = PublicConnection.SendRequest() as XmlHandler;

            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            XElement xmlCode = handler.XML.Descendants("Code").First();

            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);

            // Connection #1 : PublicAPIConnection Class
            PublicAPIConnection conn1 = new PublicAPIConnection(TestConfig.GetValueFromConfig("AppID1"),
                                                                TestConfig.GetValueFromConfig("AppSecret1"));

            conn1.URLParameters = new Dictionary <string, object>()
            {
                { "partition", TestConfig.GetValueFromConfig("Partition1") }
            };
            conn1.ServerURL   = PublicAPIConfig.ServerURL;
            conn1.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            conn1.RelativeURL = API_URL;

            // Authenticate using Connection #1
            conn1.Authentication.Authenticate();

            handler = conn1.SendRequest() as XmlHandler;
            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            xmlCode = handler.XML.Descendants("Code").First();
            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);

            // Connection #2 : PublicAPIConnection Class
            PublicAPIConnection conn2 = new PublicAPIConnection();

            conn2.URLParameters = new Dictionary <string, object>()
            {
                { "partition", TestConfig.GetValueFromConfig("Partition2") }
            };
            conn2.ServerURL   = PublicAPIConfig.ServerURL;
            conn2.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            conn2.RelativeURL = API_URL;

            // Authenticate using Connection #2
            conn2.Authentication.Authenticate(TestConfig.GetValueFromConfig("AppID2"), TestConfig.GetValueFromConfig("AppSecret2"));

            handler = conn2.SendRequest() as XmlHandler;
            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            xmlCode = handler.XML.Descendants("Code").First();
            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);
        }