Handle overrides on events when retrieving cattrs.
[mono.git] / mcs / class / System.ServiceModel / Test / System.ServiceModel / ServiceHostBaseTest.cs
index 8b91324af608c3bfbed2144cebfb0119662465dc..ac8ec625618c60f432588ef6f571c89f1eee00bb 100644 (file)
@@ -361,6 +361,57 @@ namespace MonoTests.System.ServiceModel
                        return host;
                }
 
+#if NET_4_0
+               [Test]
+               public void AddServiceEndpoint_Directly ()
+               {
+                       var host = new ServiceHost (typeof (DummyService));
+                       var address = new EndpointAddress ("http://localhost:8080");
+                       var binding = new BasicHttpBinding ();
+                       var contract = ContractDescription.GetContract (typeof (IDummyService));
+                       host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, address));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddServiceEndpoint_Directly_NullAddress ()
+               {
+                       var host = new ServiceHost (typeof (DummyService));
+                       var binding = new BasicHttpBinding ();
+                       var contract = ContractDescription.GetContract (typeof (IDummyService));
+                       host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, null));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddServiceEndpoint_Directly_NullBinding ()
+               {
+                       var host = new ServiceHost (typeof (DummyService));
+                       var address = new EndpointAddress ("http://localhost:8080");
+                       var contract = ContractDescription.GetContract (typeof (IDummyService));
+                       host.AddServiceEndpoint (new ServiceEndpoint (contract, null, address));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddServiceMetadataEndpoint ()
+               {
+                       var host = new ServiceHost (typeof (DummyService));
+                       host.AddServiceEndpoint (new ServiceMetadataEndpoint ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpoint_Directly_ContractMismatch ()
+               {
+                       var host = new ServiceHost (typeof (DummyService));
+                       var address = new EndpointAddress ("http://localhost:8080");
+                       var binding = new BasicHttpBinding ();
+                       var contract = ContractDescription.GetContract (typeof (INotImplementedService));
+                       host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, address));
+               }
+#endif
+
                #region helpers
 
                public enum Stage