**** Merged from MCS ****
[mono-project.git] / mcs / class / Microsoft.Web.Services / Test / Microsoft.Web.Services.Addressing / EndpointReference.cs
bloba5d8071ea5809d3f519b70689540511b3cec8e68
1 using System;
2 using System.Xml;
3 using NUnit.Framework;
4 using Microsoft.Web.Services.Xml;
5 using Microsoft.Web.Services.Addressing;
7 namespace Microsoft.Web.Services.Addressing.Tests
9 [TestFixture]
10 public class EndpointReferenceTests
13 [Test]
14 public void CreateEndpointReferenceFromAddress ()
16 EndpointReference e = new EndpointReference( new Address ( new Uri ("soap.tcp://127.0.0.1") ) );
18 Assert.IsNotNull (e.Address.Value);
21 [Test]
22 public void CreateEndpointReferenceFromUri ()
24 EndpointReference e = new EndpointReference( new Uri ("soap.tcp://127.0.0.1") );
26 Assert.IsNotNull (e.Address.Value);
29 [Test]
30 public void MinimalXmlToEndpointReference ()
32 XmlDocument doc = new XmlDocument ();
33 XmlElement element = doc.CreateElement ("wsa", "EndpointReference", "http://schemas.xmlsoap.org/ws/2003/03/addressing");
35 Address a = new Address ( new Uri ("soap.tcp://127.0.0.1") );
37 element.AppendChild (a.GetXml (doc));
39 EndpointReference e = new EndpointReference (element);
42 [Test]
43 public void EndpointReferenceToMinimalXml ()
45 EndpointReference e = new EndpointReference ( new Uri ("soap.tcp://127.0.0.1/") );
46 XmlElement e2 = e.GetXml (new XmlDocument ());
48 Assert.IsTrue (e2.FirstChild.InnerText == "soap.tcp://127.0.0.1/");
51 [Test]
52 public void EndpointReferenceToXmlWithPortType ()
54 EndpointReference e = new EndpointReference ( new Uri ("soap.tcp://127.0.0.1/") );
55 e.PortType = new PortType (new QualifiedName ("a","s","http://schemas.xmlsoap.org/ws/2003/03/addressing"));
57 XmlElement element = e.GetXml (new XmlDocument ());
59 Assert.IsTrue (element.FirstChild.NextSibling.InnerText == "a:s");
62 [Test]
63 public void EndpointReferenceToXmlWithProperties ()
65 EndpointReference e = new EndpointReference (new Uri ("soap.tcp://127.0.0.1/") );
66 e.ReferenceProperties = new ReferenceProperties ();
68 XmlElement element = e.GetXml (new XmlDocument ());
70 Assert.IsTrue (element.FirstChild.NextSibling.LocalName == "ReferenceProperties");
73 [Test]
74 public void EndpointReferenceToXmlWithServiceName ()
76 EndpointReference e = new EndpointReference (new Uri ("soap.tcp://127.0.0.1/") );
77 e.ServiceName = new ServiceName( new QualifiedName ("a", "s", "http://schemas.xmlsoap.org/ws/2003/03/addressing"));
78 e.ServiceName.PortName = "test";
80 XmlElement element = e.GetXml (new XmlDocument ());
82 Assert.IsTrue (element.FirstChild.NextSibling.Attributes["wsa:PortName"].InnerText == "test");
85 [Test]
86 public void RoundTripFromXml ()
88 XmlDocument doc = new XmlDocument ();
89 XmlElement element = doc.CreateElement ("wsa", "EndpointReference", "http://schemas.xmlsoap.org/ws/2003/03/addressing");
91 Address a = new Address ( new Uri ("soap.tcp://127.0.0.1") );
93 element.AppendChild (a.GetXml (doc));
95 PortType p = new PortType (new QualifiedName ("wsa", "test", "http://schemas.xmlsoap.org/ws/2003/03/addressing"));
97 element.AppendChild (p.GetXml (doc));
99 EndpointReference e = new EndpointReference (element);
101 XmlElement e2 = e.GetXml (new XmlDocument ());
103 Assert.IsNotNull (element);
104 Assert.IsNotNull (e2);
106 Assert.IsTrue (element.OuterXml == e2.OuterXml);
109 [Test]
110 public void RoundTripFromEndpointReference ()
112 EndpointReference e = new EndpointReference ( new Uri ("soap.tcp://127.0.0.1/") );
113 XmlElement e2 = e.GetXml (new XmlDocument ());
115 EndpointReference er = new EndpointReference (e2);
117 Assert.IsTrue (e.Address.Value.AbsoluteUri == er.Address.Value.AbsoluteUri);
120 //Not going to bother testing the implicit operators, they work fine.