public void TestCustomProperties() { Skip.If(_fixture.Skip, _fixture.SkipReason); var conn = CreateHttpConnection("http://tempuri.org", "en"); //Work through the interface IServerConnection isvc = (IServerConnection)conn; //UserAgent is exposed as a custom property var props = isvc.GetCustomPropertyNames(); Assert.NotNull(props); Assert.Equal(2, props.Length); Assert.True(Array.IndexOf <string>(props, HttpServerConnectionProperties.PROP_USER_AGENT) >= 0); Assert.True(Array.IndexOf <string>(props, HttpServerConnectionProperties.PROP_BASE_URL) >= 0); //It is of type string var type = isvc.GetCustomPropertyType(HttpServerConnectionProperties.PROP_USER_AGENT); Assert.Equal(typeof(string), type); type = isvc.GetCustomPropertyType(HttpServerConnectionProperties.PROP_BASE_URL); Assert.Equal(typeof(string), type); //We can set and get it isvc.SetCustomProperty(HttpServerConnectionProperties.PROP_USER_AGENT, "MapGuide Maestro API Unit Test Fixture"); var agent = (string)isvc.GetCustomProperty(HttpServerConnectionProperties.PROP_USER_AGENT); Assert.Equal("MapGuide Maestro API Unit Test Fixture", agent); //BaseUrl is read-only try { isvc.SetCustomProperty(HttpServerConnectionProperties.PROP_BASE_URL, "http://mylocalhost/mapguide"); Assert.True(false, "Should've thrown exception"); } catch { } }
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 { } }