Преглед на файлове

2010-04-02 Atsushi Enomoto <[email protected]>

	* ContractDescriptionGenerator.cs : fill FaultDescription action,
	  name and namespace as expected.

	* FaultDescriptionTest.cs : add new test.

	* FaultContractAttributeTest.cs : new test.

	* System.ServiceModel_test.dll.sources : add some new fault tests.


svn path=/trunk/mcs/; revision=154698
Atsushi Eno преди 15 години
родител
ревизия
d51ce00eba

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

@@ -1,3 +1,7 @@
+2010-04-02  Astushi Enomoto  <[email protected]>
+
+	* System.ServiceModel_test.dll.sources : add some new fault tests.
+
 2010-03-24  Astushi Enomoto  <[email protected]>
 
 	* System.ServiceModel.dll.sources : move back all the Features tests

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

@@ -1,3 +1,8 @@
+2010-04-02  Atsushi Enomoto  <[email protected]>
+
+	* ContractDescriptionGenerator.cs : fill FaultDescription action,
+	  name and namespace as expected.
+
 2010-04-02  Atsushi Enomoto  <[email protected]>
 
 	* ContractDescription.cs : fill FaultContractInfos in ClientOperation.

+ 3 - 1
mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs

@@ -246,7 +246,9 @@ namespace System.ServiceModel.Description
 					foreach (Type t in a.GetTypes ())
 						od.KnownTypes.Add (t);
 				foreach (FaultContractAttribute a in mi.GetCustomAttributes (typeof (FaultContractAttribute), false)) {
-					var fd = new FaultDescription (a.Action) { DetailType = a.DetailType, Name = a.Name, Namespace = a.Namespace };
+					var fname = a.Name ?? a.DetailType.Name + "Fault";
+					var fns = a.Namespace ?? cd.Namespace;
+					var fd = new FaultDescription (a.Action ?? cd.Namespace + cd.Name + "/" + od.Name + fname) { DetailType = a.DetailType, Name = fname, Namespace = fns };
 #if !NET_2_1
 					if (a.HasProtectionLevel)
 						fd.ProtectionLevel = a.ProtectionLevel;

+ 2 - 0
mcs/class/System.ServiceModel/System.ServiceModel_test.dll.sources

@@ -101,6 +101,7 @@ System.ServiceModel.Configuration/StandardBindingElementTest.cs
 System.ServiceModel.Configuration/UserBinding.cs
 System.ServiceModel.Description/ClientCredentialsTest.cs
 System.ServiceModel.Description/ContractDescriptionTest.cs
+System.ServiceModel.Description/FaultDescriptionTest.cs
 System.ServiceModel.Description/MetadataExchangeBindingsTest.cs
 System.ServiceModel.Description/MetadataResolverTest.cs
 System.ServiceModel.Description/OperationDescriptionTest.cs
@@ -167,6 +168,7 @@ System.ServiceModel/EndpointBehaviorCollectionTest.cs
 System.ServiceModel/EndpointIdentityTest.cs
 System.ServiceModel/ExtensionCollectionTest.cs
 System.ServiceModel/FaultCodeTest.cs
+System.ServiceModel/FaultContractAttributeTest.cs
 System.ServiceModel/FaultReasonTest.cs
 System.ServiceModel/IntegratedConnectionTest.cs
 System.ServiceModel/MessageSecurityVersionTest.cs

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

@@ -1,3 +1,7 @@
+2010-04-02  Atsushi Enomoto  <[email protected]>
+
+	* FaultDescriptionTest.cs : add new test.
+
 2010-03-29  Atsushi Enomoto  <[email protected]>
 
 	* MetadataResolverTest.cs : enable working tests.

+ 74 - 0
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/FaultDescriptionTest.cs

@@ -0,0 +1,74 @@
+//
+// FaultDescriptionTest.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// Copyright (C) 2010 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+	[TestFixture]
+	public class FaultDescriptionTest
+	{
+		[Test]
+		[ExpectedException (typeof (ArgumentNullException))]
+		public void NullAction ()
+		{
+			new FaultDescription (null);
+		}
+
+		[Test]
+		public void SimpleUse ()
+		{
+			var cd = ContractDescription.GetContract (typeof (ITestContract));
+			var od = cd.Operations [0];
+			Assert.AreEqual (1, od.Faults.Count, "#1");
+			var fd = od.Faults [0];
+			// automatically filled names
+			Assert.AreEqual ("http://tempuri.org/ITestContract/EchoMyDetailFault", fd.Action, "#2");
+			Assert.AreEqual ("MyDetailFault", fd.Name, "#3");
+			Assert.AreEqual ("http://tempuri.org/", fd.Namespace, "#4");
+		}
+
+		class MyDetail
+		{
+		}
+
+		[ServiceContract]
+		interface ITestContract
+		{
+			[OperationContract]
+			[FaultContract (typeof (MyDetail))]
+			string Echo (string input);
+		}
+	}
+}

+ 0 - 1
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/DispatchOperationTest.cs

@@ -85,7 +85,6 @@ namespace MonoTests.System.ServiceModel.Dispatcher
 		}
 
 		[Test]
-		[Category ("NotWorking")]
 		public void FaultContractInfos ()
 		{
 			var host = new ServiceHost (typeof (TestFaultContract));

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

@@ -1,3 +1,7 @@
+2010-04-01  Atsushi Enomoto  <[email protected]>
+
+	* FaultContractAttributeTest.cs : new test.
+
 2010-04-01  Atsushi Enomoto  <[email protected]>
 
 	* ServiceHostBaseTest.cs : enable RunDestinationUnreachableTest()

+ 26 - 0
mcs/class/System.ServiceModel/Test/System.ServiceModel/FaultContractAttributeTest.cs

@@ -0,0 +1,26 @@
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+	[TestFixture]
+	public class FaultContractAttributeTest
+	{
+		[Test]
+		public void Defaults ()
+		{
+			var a = new FaultContractAttribute (typeof (MyDetail));
+			Assert.AreEqual (typeof (MyDetail), a.DetailType, "#1");
+			Assert.IsNull (a.Action, "#2");
+			Assert.IsNull (a.Name, "#3");
+			Assert.IsNull (a.Namespace, "#4");
+		}
+
+		class MyDetail
+		{
+		}
+	}
+}