Explorar el Código

2010-06-18 Atsushi Enomoto <[email protected]>

	* ServiceHostTest.cs : fix AddServiceEndpoint tests to make sense.
	  They are mostly not working. Enable working one.

	* TcpTransportBindingElementTest.cs : rename misleading test.


svn path=/trunk/mcs/; revision=159122
Atsushi Eno hace 15 años
padre
commit
f5d38f374f

+ 4 - 0
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog

@@ -1,3 +1,7 @@
+2010-06-18  Atsushi Enomoto  <[email protected]>
+
+	* TcpTransportBindingElementTest.cs : rename misleading test.
+
 2010-06-17  Atsushi Enomoto  <[email protected]>
 
 	* HttpTransportBindingElementTest.cs, CustomBindingTest.cs :

+ 1 - 1
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TcpTransportBindingElementTest.cs

@@ -204,7 +204,7 @@ namespace MonoTests.System.ServiceModel.Channels
 		[Category ("NotWorking")]
 		// FIXME: To enable this, we must fix the "request-reply TCP channel must close the connection" issue.
 		// It is strange, but the standalone test just works.
-		public void SimpleDuplexStreamed () // sample[svc|cli]5.exe
+		public void SimpleRequestReplyStreamed () // sample[svc|cli]5.exe
 		{
 			ServiceHost host = new ServiceHost (typeof (Foo));
 			NetTcpBinding bindingS = new NetTcpBinding ();

+ 5 - 0
mcs/class/System.ServiceModel/Test/System.ServiceModel/ChangeLog

@@ -1,3 +1,8 @@
+2010-06-18  Atsushi Enomoto  <[email protected]>
+
+	* ServiceHostTest.cs : fix AddServiceEndpoint tests to make sense.
+	  They are mostly not working. Enable working one.
+
 2010-06-15  Atsushi Enomoto  <[email protected]>
 
 	* CallbackBehaviorAttributeTest.cs : added test for bug #567672

+ 49 - 13
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostTest.cs

@@ -107,12 +107,11 @@ namespace MonoTests.System.ServiceModel
 		}
 
 		[Test]
-		[Ignore ("AddServiceEndpoint part does not work")]
 		public void AddServiceEndpoint ()
 		{
 			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
-			host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
-			host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "svc");
+			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel");
+			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "svc");
 
 			Assert.IsNotNull (host.Description, "#6");
 			Assert.IsNotNull (host.Description.Endpoints, "#7");
@@ -126,27 +125,64 @@ namespace MonoTests.System.ServiceModel
 		{
 			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("ftp://localhost/echo"));
 			// ftp does not match BasicHttpBinding
-			host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
+			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel");
 		}
 
 		[Test]
 		[ExpectedException (typeof (InvalidOperationException))]
+		[Category ("NotWorking")]
 		public void AddServiceEndpoint2 ()
 		{
-			// IBar is not part of the contract
 			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
-			host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
-			//host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
+			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel");
+			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel"); // duplicate URI
+
+			host.Open ();
+			host.Close (); // should not reach here. It is to make sure to close unexpectedly opened host.
+		}
+
+		[Test]
+		[ExpectedException (typeof (InvalidOperationException))]
+		[Category ("NotWorking")]
+		public void AddServiceEndpoint2_2 ()
+		{
+			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
+			// same as above, but through Endpoints.Add()
+			host.Description.Endpoints.Add (new ServiceEndpoint (ContractDescription.GetContract (typeof (Foo)), new BasicHttpBinding (), new EndpointAddress ("http://localhost/echo/rel")));
+			host.Description.Endpoints.Add (new ServiceEndpoint (ContractDescription.GetContract (typeof (Foo)), new BasicHttpBinding (), new EndpointAddress ("http://localhost/echo/rel")));
+
+			host.Open ();
+			host.Close (); // should not reach here. It is to make sure to close unexpectedly opened host.
+		}
+
+		[Test]
+		[ExpectedException (typeof (InvalidOperationException))]
+		[Category ("NotWorking")] // If I blindly reject things like this, it will block Service[Debug|Metadata]Behavior functionality.
+		public void AddServiceEndpoint2_3 ()
+		{
+			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
+			host.Description.Endpoints.Add (new ServiceEndpoint (ContractDescription.GetContract (typeof (Foo)), new BasicHttpBinding (), new EndpointAddress ("http://localhost/echo")));
+			host.Description.Endpoints.Add (new ServiceEndpoint (ContractDescription.GetContract (typeof (IMetadataExchange)), new BasicHttpBinding (), new EndpointAddress ("http://localhost/echo")));
+
+			// Different contracts unlike previous two cases.
+			// If two or more endpoints are bound to the same listen
+			// URI, then they must share the same instance.
+
+			host.Open ();
+			host.Close (); // should not reach here. It is to make sure to close unexpectedly opened host.
 		}
 
 		[Test]
 		[ExpectedException (typeof (InvalidOperationException))]
+		[Category ("NotWorking")]
 		public void AddServiceEndpoint3 ()
 		{
-			// IBar is not part of the contract
 			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
-			host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
-			// host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "http://localhost/echo/rel");
+			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel");
+			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "http://localhost/echo/rel"); // duplicate URI when resolved
+
+			host.Open ();
+			host.Close (); // should not reach here. It is to make sure to close unexpectedly opened host.
 		}
 
 		[Test]
@@ -176,7 +212,7 @@ namespace MonoTests.System.ServiceModel
 
 		[Test]
 		[ExpectedException (typeof (InvalidOperationException))]
-		public void AddServiceEndpointMex ()
+		public void AddServiceEndpointMexWithNoImpl ()
 		{
 			using (ServiceHost h = new ServiceHost (typeof (Foo), new Uri ("http://localhost:8080"))) {
 				// it expects ServiceMetadataBehavior
@@ -187,11 +223,11 @@ namespace MonoTests.System.ServiceModel
 		[Test]
 		public void AddServiceEndpointMetadataExchange ()
 		{
+			// MyMetadataExchange implements IMetadataExchange
 			ServiceHost host = new ServiceHost (typeof (MyMetadataExchange));
-			// strange, but unlike above, it is accepted. The only difference I can see is the binding name.
 			host.AddServiceEndpoint ("IMetadataExchange",
 						 new BasicHttpBinding (),
-						 "http://localhost:8080");
+						 "http://localhost:8080/");
 		}
 
 		[Test]