4 using Microsoft
.Web
.Services
.Xml
;
5 using Microsoft
.Web
.Services
.Addressing
;
7 namespace Microsoft
.Web
.Services
.Addressing
.Tests
10 public class EndpointReferenceTests
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
);
22 public void CreateEndpointReferenceFromUri ()
24 EndpointReference e
= new EndpointReference( new Uri ("soap.tcp://127.0.0.1") );
26 Assert
.IsNotNull (e
.Address
.Value
);
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
);
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/");
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");
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");
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");
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
);
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.