Browse Source

2010-03-25 Atsushi Enomoto <[email protected]>

	* ServiceHostBaseTest.cs : add not-working ActionNotFound test by
	  Matt Dargavel.


svn path=/trunk/mcs/; revision=154192
Atsushi Eno 16 years ago
parent
commit
ce323b0f71

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

@@ -1,3 +1,8 @@
+2010-03-25  Atsushi Enomoto  <[email protected]>
+
+	* ServiceHostBaseTest.cs : add not-working ActionNotFound test by
+	  Matt Dargavel.
+
 2010-03-18  Atsushi Enomoto  <[email protected]>
 
 	* Constants.cs : copied from the lib itself.

+ 62 - 1
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostBaseTest.cs

@@ -323,6 +323,35 @@ namespace MonoTests.System.ServiceModel
 			Assert.Fail ("should not open");
 		}
 
+		[Test]
+		[Category ("NotWorking")]
+		public void RunDestinationUnreachableTest ()
+		{
+			string address = "http://localhost:37564/";
+			var host = OpenHost (address);
+			
+			var binding = new BasicHttpBinding ();
+			var client = new DestinationUnreachableClient (binding, address);
+			
+			try {
+				client.NotImplementedOperation ();
+				Assert.Fail ("ActionNotSupportedException is expected");
+			} catch (ActionNotSupportedException) {
+				// catching it instead of ExpectedException to distinguish errors at service side.
+			}
+		}
+		
+		ServiceHost OpenHost (string address)
+		{
+			var baseAddresses = new Uri[] { new Uri(address) };
+
+			var host = new ServiceHost (typeof (DummyService), baseAddresses);
+			var basicBinding = new BasicHttpBinding ();
+			host.AddServiceEndpoint (typeof (IDummyService), basicBinding, new Uri ("", UriKind.Relative));
+			host.Open ();
+			return host;
+		}
+
 		#region helpers
 
 		public enum Stage
@@ -606,7 +635,39 @@ namespace MonoTests.System.ServiceModel
 
 			#endregion
 		}
-		#endregion
 
+		[ServiceContract]
+		public interface IDummyService
+		{
+			[OperationContract]
+			void DummyOperation ();
+		}
+		public class DummyService : IDummyService
+		{
+			public void DummyOperation ()
+			{
+				// Do nothing
+			}
+		}
+		[ServiceContract]
+		public interface INotImplementedService
+		{
+			[OperationContract]
+			void NotImplementedOperation ();
+		}
+		public class DestinationUnreachableClient : ClientBase<INotImplementedService>, INotImplementedService
+		{
+			public void NotImplementedOperation ()
+			{
+				Channel.NotImplementedOperation ();
+			}
+		
+			public DestinationUnreachableClient (Binding binding, string address) 
+				: base (binding, new EndpointAddress (address))
+			{
+			}
+		}
+
+		#endregion
 	}
 }