Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }