Ejemplo n.º 1
0
        public void TestCustomProperties()
        {
            var builder = new RequestBuilder(new Uri("http://tempuri.org"), "en");
            var conn = new HttpServerConnection(builder);

            //Work through the interface
            IServerConnection isvc = (IServerConnection)conn;

            //UserAgent is exposed as a custom property
            var props = isvc.GetCustomPropertyNames();

            Assert.IsNotNull(props);
            Assert.AreEqual(props.Length, 2);
            Assert.IsTrue(Array.IndexOf<string>(props, HttpServerConnection.PROP_USER_AGENT) >= 0);
            Assert.IsTrue(Array.IndexOf<string>(props, HttpServerConnection.PROP_BASE_URL) >= 0);

            //It is of type string
            var type = isvc.GetCustomPropertyType(HttpServerConnection.PROP_USER_AGENT);
            Assert.AreEqual(type, typeof(string));
            type = isvc.GetCustomPropertyType(HttpServerConnection.PROP_BASE_URL);
            Assert.AreEqual(type, typeof(string));

            //We can set and get it
            isvc.SetCustomProperty(HttpServerConnection.PROP_USER_AGENT, "MapGuide Maestro API Unit Test Fixture");
            var agent = (string)isvc.GetCustomProperty(HttpServerConnection.PROP_USER_AGENT);
            Assert.AreEqual(agent, "MapGuide Maestro API Unit Test Fixture");

            //BaseUrl is read-only
            try
            {
                isvc.SetCustomProperty(HttpServerConnection.PROP_BASE_URL, "http://mylocalhost/mapguide");
                Assert.Fail("Should've thrown exception");
            }
            catch { }
        }
Ejemplo n.º 2
0
 internal HttpCoordinateSystemCatalog(HttpServerConnection con, RequestBuilder req)
 {
     m_con = con;
     m_req = req;
 }
Ejemplo n.º 3
0
        public void TestServiceCapabilities()
        {
            var builder = new RequestBuilder(new Uri("http://tempuri.org"), "en");
            var conn = new HttpServerConnection(builder);
            conn.SetSiteVersion(new Version(1, 2, 0));

            //Work through the interface
            IServerConnection isvc = (IServerConnection)conn;
            int[] stypes = isvc.Capabilities.SupportedServices;
            foreach (int st in stypes)
            {
                try
                {
                    IService svc = isvc.GetService(st);
                }
                catch
                {
                    Assert.Fail("Supported service type mismatch");
                }
            }

            conn.SetSiteVersion(new Version(2, 0, 0));

            stypes = isvc.Capabilities.SupportedServices;
            foreach (int st in stypes)
            {
                try
                {
                    IService svc = isvc.GetService(st);
                }
                catch
                {
                    Assert.Fail("Supported service type mismatch");
                }
            }
        }