Esempio n. 1
0
        public void It_writes_must_understand()
        {
            var header = new MessageHeader(XName.Get("headerName", "headerNamespace"), new XNode[] {}, true);

            var headerElement = XElementExtensions.ParseGeneratedXml(header.Write);

            Assert.AreEqual("true", headerElement.Attribute(Constants.Namespace + "mustUnderstand").Value);
        }
Esempio n. 2
0
        public void It_writes_header_name_with_namespace()
        {
            var header = new MessageHeader(XName.Get("headerName", "headerNamespace"), new XNode[] { }, true);

            var headerElement = XElementExtensions.ParseGeneratedXml(header.Write);

            Assert.AreEqual("headerName", headerElement.Name.LocalName);
            Assert.AreEqual("headerNamespace", headerElement.Name.NamespaceName);
        }
        public void It_sets_fault_action()
        {
            var message = FaultMessage.Create("someAction", "no reason", FaultCode.Sender, Enumerable.Empty <XmlQualifiedName>());

            var envelope = XElementExtensions.ParseGeneratedXml(message.Write);

            var headerSectionElement = envelope.Element(Constants.Header);
            var actionHeader         = headerSectionElement.Element(Addressing.Constants.Namespace + "Action");
            var actionValue          = ((XText)actionHeader.FirstNode).Value;

            Assert.AreEqual("someAction", actionValue);
        }
        public void It_reads_first_reason()
        {
            var outgoingMessage = FaultMessage.Create(
                "someAction",
                "no reason",
                FaultCode.Sender,
                new[] { FaultCode.Receiver });

            var reader          = XElementExtensions.ParseGeneratedXml(outgoingMessage.Write).ToReader();
            var incomingMessage = new IncomingMessage(reader);
            var exception       = incomingMessage.CreateFaultException();

            Assert.AreEqual("no reason", exception.Reason);
        }
Esempio n. 5
0
        public void It_writes_body()
        {
            var bodyWriter = new XElementWriter(new XElement("Body"));
            var message    = new OutgoingMessage();

            message.SetBody(bodyWriter);

            var envelope = XElementExtensions.ParseGeneratedXml(message.Write);

            Assert.AreEqual(SOAP.Constants.Envelope, envelope.Name);
            var bodySectionElement = envelope.Element(SOAP.Constants.Body);
            var bodyElement        = (XElement)bodySectionElement.FirstNode;

            Assert.AreEqual("Body", bodyElement.Name.LocalName);
        }
        public void It_reads_fault_code_with_nested_subcodes()
        {
            var outgoingMessage = FaultMessage.Create(
                "someAction",
                "no reason",
                FaultCode.Sender,
                new [] { FaultCode.Receiver, FaultCode.VersionMismatch });

            var reader          = XElementExtensions.ParseGeneratedXml(outgoingMessage.Write).ToReader();
            var incomingMessage = new IncomingMessage(reader);
            var exception       = incomingMessage.CreateFaultException();

            Assert.AreEqual(FaultCode.Sender, exception.Code);
            Assert.IsTrue(new [] { FaultCode.Receiver, FaultCode.VersionMismatch }.SequenceEqual(exception.Subcodes));
        }
        public void It_sets_fault_code_with_nested_subcodes()
        {
            var message = FaultMessage.Create("someAction", "no reason", FaultCode.Sender, new [] { FaultCode.Receiver, FaultCode.VersionMismatch });

            var envelope = XElementExtensions.ParseGeneratedXml(message.Write);

            var bodyElement = envelope.Element(Constants.Body);
            var codeElement = bodyElement
                              .Element(Constants.Namespace + "Fault")
                              .Element(Constants.Namespace + "Code");

            var rootSubcodeElement  = codeElement.Element(Constants.Namespace + "Subcode");
            var childSubcodeElement = rootSubcodeElement.Element(Constants.Namespace + "Subcode");

            Assert.AreEqual("Sender", ExtractCodeValue(codeElement));
            Assert.AreEqual("Receiver", ExtractCodeValue(rootSubcodeElement));
            Assert.AreEqual("VersionMismatch", ExtractCodeValue(childSubcodeElement));
        }
Esempio n. 8
0
        public void It_writes_header_contents()
        {
            var header = new MessageHeader(XName.Get("headerName", "headerNamespace"),
                                           new XNode[]
            {
                new XText("someText"),
                new XElement("someNestedElement")
            }, true);

            var headerElement  = XElementExtensions.ParseGeneratedXml(header.Write);
            var headerContents = headerElement.Nodes().ToList();
            var textNode       = (XText)headerContents[0];

            Assert.AreEqual("someText", textNode.Value);
            var nestedElement = (XElement)headerContents[1];

            Assert.AreEqual("someNestedElement", nestedElement.Name.LocalName);
        }
Esempio n. 9
0
        public void It_writes_headers()
        {
            var message = new OutgoingMessage();

            var headerName = XName.Get("someHeader", "someNamespace");
            var header     = new MessageHeader(
                headerName,
                new XNode[] { new XText("someText") },
                false);

            message.AddHeader(header);

            var envelope = XElementExtensions.ParseGeneratedXml(message.Write);

            Assert.AreEqual(SOAP.Constants.Envelope, envelope.Name);
            var headerSectionElement = envelope.Element(SOAP.Constants.Header);
            var headerElement        = headerSectionElement.Element(headerName);
            var headerContent        = (XText)headerElement.FirstNode;

            Assert.AreEqual("someText", headerContent.Value);
        }