Пример #1
0
 public void Validate_Throws_With_Non_ManualAddressing()
 {
     HttpBehavior behavior = new HttpBehavior();
     ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService)));
     BindingElementCollection bindingElements = new HttpBinding().CreateBindingElements();
     (bindingElements[bindingElements.Count - 1] as HttpTransportBindingElement).ManualAddressing = false;
     endpoint.Binding = new CustomBinding(bindingElements);
     endpoint.Address = new EndpointAddress("http://somehost");
     ExceptionAssert.Throws<InvalidOperationException>(
          "Non-manual addressing should throw",
          Http.SR.InvalidManualAddressingValue(endpoint.Address.Uri.AbsoluteUri),
          () => behavior.Validate(endpoint));
 }
Пример #2
0
        public void Validate_Throws_With_Non_HttpMessageEncodingBindingElement()
        {
            HttpBehavior behavior = new HttpBehavior();
            ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService)));
            WebHttpBinding webHttpBinding = new WebHttpBinding();
            endpoint.Binding = webHttpBinding;
            endpoint.Address = new EndpointAddress("http://somehost");

            ExceptionAssert.Throws<InvalidOperationException>(
                "Non-HttpMessageEncodingBindingElement should throw",
                Http.SR.InvalidMessageEncodingBindingElement(
                    endpoint.Address.Uri.AbsoluteUri,
                    typeof(MessageEncodingBindingElement).Name,
                    typeof(HttpMessageEncodingBindingElement).Name),
                () => behavior.Validate(endpoint));
        }
Пример #3
0
 public void Validate_Throws_With_Non_Http_Binding()
 {
     HttpBehavior behavior = new HttpBehavior();
     ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService)));
     NetTcpBinding netTcpBinding = new NetTcpBinding();
     endpoint.Binding = netTcpBinding;
     endpoint.Address = new EndpointAddress("http://somehost");
     ExceptionAssert.Throws<InvalidOperationException>(
          "Non-Http Binding should throw",
          Http.SR.InvalidUriScheme(endpoint.Address.Uri.AbsoluteUri),
          () => behavior.Validate(endpoint));
 }
Пример #4
0
        public void Validate_Throws_If_XmlSerializerFormat_With_Rpc_Format_Style()
        {
            HttpBehavior behavior = new HttpBehavior();

            ContractDescription description = ContractDescription.GetContract(typeof(CustomerService));
            ServiceEndpoint endpoint = new ServiceEndpoint(description);
            endpoint.Binding = new HttpBinding();
            endpoint.Address = new EndpointAddress("http://somehost");

            OperationDescription od = description.Operations[0];
            XmlSerializerFormatAttribute attr = new XmlSerializerFormatAttribute() { Style = OperationFormatStyle.Rpc };
            od.Behaviors.Add(new XmlSerializerOperationBehavior(od, attr));

            ExceptionAssert.Throws<InvalidOperationException>(
                 "XmlSerializerFormat with RPC should throw",
                 Http.SR.InvalidXmlSerializerFormatAttribute(
                    od.Name,
                    od.DeclaringContract.Name,
                    typeof(XmlSerializerFormatAttribute).Name),
                 () => behavior.Validate(endpoint));
        }
Пример #5
0
 public void Validate_Throws_With_Endpoint_Address_Headers()
 {
     HttpBehavior behavior = new HttpBehavior();
     ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService)));
     endpoint.Binding = new HttpBinding();
     AddressHeader[] headers = new AddressHeader[] { AddressHeader.CreateAddressHeader("hello") };
     endpoint.Address = new EndpointAddress(new Uri("http://somehost"), headers);
     ExceptionAssert.Throws<InvalidOperationException>(
         "Address with headers should throw",
         Http.SR.HttpServiceEndpointCannotHaveMessageHeaders(endpoint.Address),
         () => behavior.Validate(endpoint));
 }
Пример #6
0
        public void Validate_Throws_If_Response_Message_Headers_Present()
        {
            HttpBehavior behavior = new HttpBehavior();

            ContractDescription description = ContractDescription.GetContract(typeof(CustomerService));
            ServiceEndpoint endpoint = new ServiceEndpoint(description);
            endpoint.Binding = new HttpBinding();
            endpoint.Address = new EndpointAddress("http://somehost");

            OperationDescription od = description.Operations[0];
            od.Messages[1].Headers.Add(new MessageHeaderDescription("someName", "someNamespace"));

            ExceptionAssert.Throws<InvalidOperationException>(
                 "An operation with response message headers should throw",
                 Http.SR.InvalidOperationWithMessageHeaders(od.Name, od.DeclaringContract.Name),
                 () => behavior.Validate(endpoint));
        }
Пример #7
0
 public void Validate_Does_Not_Throw_For_HttpBinding()
 {
     HttpBehavior behavior = new HttpBehavior();
     ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService)));
     endpoint.Binding = new HttpBinding();
     endpoint.Address = new EndpointAddress("http://somehost");
     behavior.Validate(endpoint);
 }
Пример #8
0
        public void Validate_Throws_With_Null_Endpoint()
        {
            HttpBehavior behavior = new HttpBehavior();

            ExceptionAssert.ThrowsArgumentNull("endpoint", () => behavior.Validate(null));
        }
Пример #9
0
        public void Validate_Throws_With_Null_Binding_On_Endpoint()
        {
            HttpBehavior behavior = new HttpBehavior();
            ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService)));

            ExceptionAssert.Throws<InvalidOperationException>(
                "Validate should throw for null binding",
                Http.SR.HttpBehaviorBindingRequired(typeof(HttpBehavior).Name),
                () => behavior.Validate(endpoint));
        }
Пример #10
0
 public void Validate_Throws_With_Non_MessageVersion_None()
 {
     HttpBehavior behavior = new HttpBehavior();
     ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService)));
     endpoint.Binding = new BasicHttpBinding();
     endpoint.Address = new EndpointAddress("http://somehost");
     ExceptionAssert.Throws<InvalidOperationException>(
          "Non-MessageVersion.None should throw",
          Http.SR.InvalidMessageVersion(endpoint.Address.Uri.AbsoluteUri),
          () => behavior.Validate(endpoint));
 }