public void Endpoint_Ctor_Initializes_All_Properties() { HttpEndpointElement el = new HttpEndpointElement(); Assert.AreEqual(HttpBehavior.DefaultHelpEnabled, el.HelpEnabled, "HelpEnabled wrong"); Assert.AreEqual(HttpBehavior.DefaultTrailingSlashMode, el.TrailingSlashMode, "TrailingSlashMode wrong"); Assert.AreEqual(string.Empty, el.OperationHandlerFactory, "HttpOperationHandlerFactory should default to empty"); HostNameComparisonMode mode = el.HostNameComparisonMode; Assert.AreEqual(HostNameComparisonMode.StrongWildcard, mode, "HostNameComparisonMode failed"); long maxBufferPoolSize = el.MaxBufferPoolSize; long expectedMaxBufferPoolSize = 0x80000L; Assert.AreEqual(expectedMaxBufferPoolSize, maxBufferPoolSize, "MaxBufferPoolSize failed"); Assert.AreEqual(0x10000, el.MaxBufferSize, "MaxBufferSize failed"); Assert.AreEqual(0x10000L, el.MaxReceivedMessageSize, "MaxReceivedMessageSize failed"); HttpBindingSecurityElement secElement = el.Security; Assert.IsNotNull(secElement, "Security failed"); TransferMode xferMode = el.TransferMode; Assert.AreEqual(TransferMode.Buffered, xferMode, "TransferMode failed"); }
public void Endpoint_Set_Properties() { HttpEndpointElement el = new HttpEndpointElement(); el.HelpEnabled = false; Assert.IsFalse(el.HelpEnabled, "HelpEnabled false"); el.HelpEnabled = true; Assert.IsTrue(el.HelpEnabled, "HelpEnabled true"); el.TrailingSlashMode = TrailingSlashMode.AutoRedirect; Assert.AreEqual(TrailingSlashMode.AutoRedirect, el.TrailingSlashMode, "Autoredirect failed"); el.TrailingSlashMode = TrailingSlashMode.Ignore; Assert.AreEqual(TrailingSlashMode.Ignore, el.TrailingSlashMode, "Ignore failed"); el.OperationHandlerFactory = "hello"; Assert.AreEqual("hello", el.OperationHandlerFactory, "HttpOperationHandlerFactory failed"); el.OperationHandlerFactory = null; Assert.AreEqual(string.Empty, el.OperationHandlerFactory, "Null handler provider failed"); el.OperationHandlerFactory = " "; Assert.AreEqual(string.Empty, el.OperationHandlerFactory, "whitespace handler provider failed"); el.HostNameComparisonMode = HostNameComparisonMode.Exact; Assert.AreEqual(HostNameComparisonMode.Exact, el.HostNameComparisonMode, "Exact failed"); el.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; Assert.AreEqual(HostNameComparisonMode.StrongWildcard, el.HostNameComparisonMode, "StrongWildcard failed"); el.HostNameComparisonMode = HostNameComparisonMode.WeakWildcard; Assert.AreEqual(HostNameComparisonMode.WeakWildcard, el.HostNameComparisonMode, "WeakWildcard failed"); el.MaxBufferPoolSize = long.MaxValue; Assert.AreEqual(long.MaxValue, el.MaxBufferPoolSize, "MaxBufferPoolSize max failed"); el.MaxBufferPoolSize = 0L; Assert.AreEqual(0L, el.MaxBufferPoolSize, "MaxBufferPoolSize min failed"); el.MaxBufferSize = int.MaxValue; Assert.AreEqual(int.MaxValue, el.MaxBufferSize, "MaxBufferSize max failed"); el.MaxBufferSize = 1; Assert.AreEqual(1, el.MaxBufferSize, "MaxBufferSize 1 failed"); el.MaxReceivedMessageSize = long.MaxValue; Assert.AreEqual(long.MaxValue, el.MaxReceivedMessageSize, "MaxReceivedMessageSize max failed"); el.MaxReceivedMessageSize = 1; Assert.AreEqual(1, el.MaxReceivedMessageSize, "MaxReceivedMessageSize 1 failed"); el.TransferMode = TransferMode.Buffered; Assert.AreEqual(TransferMode.Buffered, el.TransferMode, "Buffered failed"); el.TransferMode = TransferMode.Streamed; Assert.AreEqual(TransferMode.Streamed, el.TransferMode, "Streamed failed"); el.TransferMode = TransferMode.StreamedRequest; Assert.AreEqual(TransferMode.StreamedRequest, el.TransferMode, "StreamedRequest failed"); el.TransferMode = TransferMode.StreamedResponse; Assert.AreEqual(TransferMode.StreamedResponse, el.TransferMode, "StreamedResponse failed"); }
public void Endpoint_Throws_OnInitializeAndValidate_Client() { HttpEndpointElement el = new HttpEndpointElement(); ChannelEndpointElement channelEndpoint = new ChannelEndpointElement(); // Protected method in sealed class requires reflection to invoke MethodInfo methodInfo = el.GetType().GetMethod( "OnInitializeAndValidate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(ChannelEndpointElement) }, null); ExceptionAssert.Throws <TargetInvocationException>( "ApplyConfiguration throws for client channel entry point", () => methodInfo.Invoke(el, new object[] { channelEndpoint }), (e) => Assert.AreEqual(Http.SR.HttpEndpointNotSupported("HttpEndpoint", "HttpClient"), e.InnerException.Message)); }
public void Endpoint_Throws_OnInitializeAndValidate_Wrong_Binding() { HttpEndpointElement el = new HttpEndpointElement(); ServiceEndpointElement endpointElement = new ServiceEndpointElement() { Binding = "bindingThatDoesntMatchExpected" }; // Protected method in sealed class requires reflection to invoke MethodInfo methodInfo = el.GetType().GetMethod( "OnInitializeAndValidate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(ServiceEndpointElement) }, null); ExceptionAssert.Throws <TargetInvocationException>( "ApplyConfiguration throws for wrong binding", () => methodInfo.Invoke(el, new object[] { endpointElement }), (e) => Assert.AreEqual(Http.SR.HttpEndpointRequiredBinding(typeof(HttpEndpoint).Name, "httpBinding"), e.InnerException.Message)); }
public void Endpoint_Ctor_Initializes_All_Properties() { HttpEndpointElement el = new HttpEndpointElement(); Assert.AreEqual(HttpBehavior.DefaultHelpEnabled, el.HelpEnabled, "HelpEnabled wrong"); Assert.AreEqual(HttpBehavior.DefaultTrailingSlashMode, el.TrailingSlashMode, "TrailingSlashMode wrong"); Assert.AreEqual(string.Empty, el.OperationHandlerFactory, "HttpOperationHandlerFactory should default to empty"); HostNameComparisonMode mode = el.HostNameComparisonMode; Assert.AreEqual(HostNameComparisonMode.StrongWildcard, mode, "HostNameComparisonMode failed"); long maxBufferPoolSize = el.MaxBufferPoolSize; long expectedMaxBufferPoolSize = 0x80000L; Assert.AreEqual(expectedMaxBufferPoolSize, maxBufferPoolSize, "MaxBufferPoolSize failed"); Assert.AreEqual(0x10000, el.MaxBufferSize, "MaxBufferSize failed"); Assert.AreEqual(0x10000L, el.MaxReceivedMessageSize, "MaxReceivedMessageSize failed"); HttpBindingSecurityElement secElement = el.Security; Assert.IsNotNull(secElement, "Security failed"); TransferMode xferMode = el.TransferMode; Assert.AreEqual(TransferMode.Buffered, xferMode, "TransferMode failed"); }
public void Endpoint_Set_Properties() { HttpEndpointElement el = new HttpEndpointElement(); el.HelpEnabled = false; Assert.IsFalse(el.HelpEnabled, "HelpEnabled false"); el.HelpEnabled = true; Assert.IsTrue(el.HelpEnabled, "HelpEnabled true"); el.TrailingSlashMode = TrailingSlashMode.AutoRedirect; Assert.AreEqual(TrailingSlashMode.AutoRedirect, el.TrailingSlashMode, "Autoredirect failed"); el.TrailingSlashMode = TrailingSlashMode.Ignore; Assert.AreEqual(TrailingSlashMode.Ignore, el.TrailingSlashMode, "Ignore failed"); el.OperationHandlerFactory = "hello"; Assert.AreEqual("hello", el.OperationHandlerFactory, "HttpOperationHandlerFactory failed"); el.OperationHandlerFactory = null; Assert.AreEqual(string.Empty, el.OperationHandlerFactory, "Null handler provider failed"); el.OperationHandlerFactory = " "; Assert.AreEqual(string.Empty, el.OperationHandlerFactory, "whitespace handler provider failed"); el.HostNameComparisonMode = HostNameComparisonMode.Exact; Assert.AreEqual(HostNameComparisonMode.Exact, el.HostNameComparisonMode, "Exact failed"); el.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; Assert.AreEqual(HostNameComparisonMode.StrongWildcard, el.HostNameComparisonMode, "StrongWildcard failed"); el.HostNameComparisonMode = HostNameComparisonMode.WeakWildcard; Assert.AreEqual(HostNameComparisonMode.WeakWildcard, el.HostNameComparisonMode, "WeakWildcard failed"); el.MaxBufferPoolSize = long.MaxValue; Assert.AreEqual(long.MaxValue, el.MaxBufferPoolSize, "MaxBufferPoolSize max failed"); el.MaxBufferPoolSize = 0L; Assert.AreEqual(0L, el.MaxBufferPoolSize, "MaxBufferPoolSize min failed"); el.MaxBufferSize = int.MaxValue; Assert.AreEqual(int.MaxValue, el.MaxBufferSize, "MaxBufferSize max failed"); el.MaxBufferSize = 1; Assert.AreEqual(1, el.MaxBufferSize, "MaxBufferSize 1 failed"); el.MaxReceivedMessageSize = long.MaxValue; Assert.AreEqual(long.MaxValue, el.MaxReceivedMessageSize, "MaxReceivedMessageSize max failed"); el.MaxReceivedMessageSize = 1; Assert.AreEqual(1, el.MaxReceivedMessageSize, "MaxReceivedMessageSize 1 failed"); el.TransferMode = TransferMode.Buffered; Assert.AreEqual(TransferMode.Buffered, el.TransferMode, "Buffered failed"); el.TransferMode = TransferMode.Streamed; Assert.AreEqual(TransferMode.Streamed, el.TransferMode, "Streamed failed"); el.TransferMode = TransferMode.StreamedRequest; Assert.AreEqual(TransferMode.StreamedRequest, el.TransferMode, "StreamedRequest failed"); el.TransferMode = TransferMode.StreamedResponse; Assert.AreEqual(TransferMode.StreamedResponse, el.TransferMode, "StreamedResponse failed"); }
public void Endpoint_Throws_OnInitializeAndValidate_Wrong_Binding() { HttpEndpointElement el = new HttpEndpointElement(); ServiceEndpointElement endpointElement = new ServiceEndpointElement() { Binding = "bindingThatDoesntMatchExpected" }; // Protected method in sealed class requires reflection to invoke MethodInfo methodInfo = el.GetType().GetMethod( "OnInitializeAndValidate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(ServiceEndpointElement) }, null); ExceptionAssert.Throws<TargetInvocationException>( "ApplyConfiguration throws for wrong binding", () => methodInfo.Invoke(el, new object[] { endpointElement }), (e) => Assert.AreEqual(Http.SR.HttpEndpointRequiredBinding(typeof(HttpEndpoint).Name, "httpBinding"), e.InnerException.Message)); }
public void Endpoint_Throws_OnInitializeAndValidate_Client() { HttpEndpointElement el = new HttpEndpointElement(); ChannelEndpointElement channelEndpoint = new ChannelEndpointElement(); // Protected method in sealed class requires reflection to invoke MethodInfo methodInfo = el.GetType().GetMethod( "OnInitializeAndValidate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(ChannelEndpointElement) }, null); ExceptionAssert.Throws<TargetInvocationException>( "ApplyConfiguration throws for client channel entry point", () => methodInfo.Invoke(el, new object[] { channelEndpoint }), (e) => Assert.AreEqual(Http.SR.HttpEndpointNotSupported("HttpEndpoint","HttpClient"), e.InnerException.Message)); }