Author: atsushi
Date: 2008-02-13 07:53:55 -0500 (Wed, 13 Feb 2008)
New Revision: 95574

Added:
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebScriptEnablingBehavior.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/QueryStringConverterTest.cs
Modified:
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/IXmlJsonReaderInitializer.cs
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/IXmlJsonWriterInitializer.cs
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReader.cs
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReaderWriterFactory.cs
   
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonWriter.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/QueryStringConverter.cs
   trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
   
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonReaderTest.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonWriterTest.cs
Log:
2008-02-13  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * WebScriptEnablingBehavior.cs : new stub.

        * QueryStringConverter.cs: CanConvert() supports cpl more types.
          Implemented ConvertStringToValue() and ConvertValueToString().

        * QueryStringConverterTest.cs : new test.




Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer.cs
___________________________________________________________________
Name: svn:executable
   - *


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/IXmlJsonReaderInitializer.cs
___________________________________________________________________
Name: svn:executable
   - *


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/IXmlJsonWriterInitializer.cs
___________________________________________________________________
Name: svn:executable
   - *


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReader.cs
___________________________________________________________________
Name: svn:executable
   - *


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonReaderWriterFactory.cs
___________________________________________________________________
Name: svn:executable
   - *


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonWriter.cs
___________________________________________________________________
Name: svn:executable
   - *

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
 2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
 2008-02-13 12:53:55 UTC (rev 95574)
@@ -1,3 +1,7 @@
+2008-02-13  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * WebScriptEnablingBehavior.cs : new stub.
+
 2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WebHttpBehavior.cs : some implementation (sorta wrong).

Added: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebScriptEnablingBehavior.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebScriptEnablingBehavior.cs
      2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebScriptEnablingBehavior.cs
      2008-02-13 12:53:55 UTC (rev 95574)
@@ -0,0 +1,94 @@
+//
+// WebScriptEnablingBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 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.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Web;
+
+namespace System.ServiceModel.Description
+{
+       public sealed class WebScriptEnablingBehavior : WebHttpBehavior
+       {
+               public WebScriptEnablingBehavior ()
+               {
+               }
+
+               WebMessageFormat default_request_format, 
default_response_format;
+               WebMessageBodyStyle default_body_style;
+
+               [MonoTODO]
+               public override WebMessageBodyStyle DefaultBodyStyle {
+                       get { return default_body_style; }
+                       set { default_body_style = value; }
+               }
+
+               [MonoTODO]
+               public override WebMessageFormat DefaultOutgoingRequestFormat {
+                       get { return default_request_format; }
+                       set { default_request_format = value; }
+               }
+
+               [MonoTODO]
+               public override WebMessageFormat DefaultOutgoingResponseFormat {
+                       get { return default_response_format; }
+                       set { default_response_format = value; }
+               }
+
+               [MonoTODO]
+               protected override void AddClientErrorInspector 
(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
+               {
+               }
+
+               [MonoTODO]
+               protected override void AddServerErrorHandlers (ServiceEndpoint 
endpoint, EndpointDispatcher endpointDispatcher)
+               {
+               }
+
+               [MonoTODO]
+               public override void ApplyClientBehavior (ServiceEndpoint 
endpoint, ClientRuntime clientRuntime)
+               {
+               }
+
+               public override void ApplyDispatchBehavior (ServiceEndpoint 
endpoint, EndpointDispatcher endpointDispatcher)
+               {
+               }
+
+               [MonoTODO]
+               protected override QueryStringConverter GetQueryStringConverter 
(OperationDescription operationDescription)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override void Validate (ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebScriptEnablingBehavior.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-13 12:53:55 UTC (rev 95574)
@@ -1,3 +1,8 @@
+2008-02-13  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * QueryStringConverter.cs: CanConvert() supports cpl more types.
+         Implemented ConvertStringToValue() and ConvertValueToString().
+
 2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WebHttpDispatchOperationSelector.cs : stubbed members.

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/QueryStringConverter.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/QueryStringConverter.cs
    2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/QueryStringConverter.cs
    2008-02-13 12:53:55 UTC (rev 95574)
@@ -27,6 +27,7 @@
 //
 using System;
 using System.ComponentModel;
+using System.Globalization;
 using System.ServiceModel;
 using System.ServiceModel.Description;
 
@@ -43,26 +44,94 @@
                        case TypeCode.Empty:
                                return false;
                        case TypeCode.Object:
+                               if (type == typeof (TimeSpan))
+                                       return true;
+                               if (type == typeof (DateTimeOffset))
+                                       return true;
                                if (type == typeof (Guid))
                                        return true;
-                               if (type.GetCustomAttributes (typeof 
(TypeConverterAttribute), true).Length > 0)
+                               if (type == typeof (object))
                                        return true;
+//                             if (type.GetCustomAttributes (typeof 
(TypeConverterAttribute), true).Length > 0)
+//                                     return true;
                                return false;
                        default:
                                return true;
                        }
                }
 
-               [MonoTODO]
                public virtual object ConvertStringToValue (string parameter, 
Type parameterType)
                {
-                       throw new NotImplementedException ();
+                       if (parameterType == null)
+                               throw new ArgumentNullException 
("parameterType");
+
+                       if (!CanConvert (parameterType))
+                               throw new NotSupportedException (String.Format 
("Conversion from the argument parameterType '{0}' is not supported", 
parameterType));
+
+                       // FIXME: implement null string to default value 
conversion.
+
+                       switch (Type.GetTypeCode (parameterType)) {
+                       case TypeCode.String:
+                               return parameter;
+                       case TypeCode.Char:
+                               return Char.Parse (parameter);
+                       case TypeCode.SByte:
+                               return SByte.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Byte:
+                               return Byte.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Int16:
+                               return Int16.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Int32:
+                               return Int32.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Int64:
+                               return Int64.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.UInt16:
+                               return UInt16.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.UInt32:
+                               return UInt32.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.UInt64:
+                               return UInt64.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.DateTime:
+                               return DateTime.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Boolean:
+                               return Boolean.Parse (parameter);
+                       case TypeCode.Single:
+                               return Single.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Double:
+                               return Double.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Decimal:
+                               return Decimal.Parse (parameter, 
CultureInfo.InvariantCulture);
+                       case TypeCode.Object:
+                               if (parameterType == typeof (TimeSpan))
+                                       return TimeSpan.Parse (parameter);
+                               if (parameterType == typeof (DateTimeOffset))
+                                       return DateTimeOffset.Parse (parameter, 
CultureInfo.InvariantCulture);
+                               if (parameterType == typeof (Guid))
+                                       return new Guid (parameter);
+                               break;
+                       }
+                       throw new NotSupportedException (String.Format ("Cannot 
convert parameter string '{0}' to parameter type '{1}'", parameter, 
parameterType));
                }
 
-               [MonoTODO]
                public virtual string ConvertValueToString (object parameter, 
Type parameterType)
                {
-                       throw new NotImplementedException ();
+                       if (parameterType == null)
+                               throw new ArgumentNullException 
("parameterType");
+                       if (parameterType.IsValueType && parameter == null)
+                               throw new ArgumentNullException ("parameter");
+
+                       if (parameter == null)
+                               return null;
+
+                       if (parameter.GetType () != parameterType)
+                               throw new InvalidCastException (String.Format 
("This QueryStringConverter does not support cast from {0} to {1}", 
parameter.GetType (), parameterType));
+
+                       if (!CanConvert (parameterType))
+                               throw new NotSupportedException (String.Format 
("Conversion from the argument parameterType '{0}' is not supported", 
parameterType));
+
+                       if (parameter is IFormattable)
+                               ((IFormattable) parameter).ToString (null, 
CultureInfo.InvariantCulture);
+                       return parameter.ToString ();
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2008-02-13 12:53:55 UTC (rev 95574)
@@ -18,6 +18,7 @@
 System.ServiceModel.Channels/WebMessageEncoderFactory.cs
 System.ServiceModel.Channels/WebMessageEncodingBindingElement.cs
 System.ServiceModel.Description/WebHttpBehavior.cs
+System.ServiceModel.Description/WebScriptEnablingBehavior.cs
 System.ServiceModel.Dispatcher/JsonQueryStringConverter.cs
 System.ServiceModel.Dispatcher/QueryStringConverter.cs
 System.ServiceModel.Dispatcher/WebHttpDispatchOperationSelector.cs

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2008-02-13 12:53:55 UTC (rev 95574)
@@ -4,6 +4,7 @@
 System.ServiceModel.Channels/WebBodyFormatMessagePropertyTest.cs
 System.ServiceModel.Channels/WebMessageEncodingBindingElementTest.cs
 System.ServiceModel.Description/WebHttpBehaviorTest.cs
+System.ServiceModel.Dispatcher/QueryStringConverterTest.cs
 System.ServiceModel.Syndication/Atom10FeedFormatterTest.cs
 System.ServiceModel.Syndication/Atom10ItemFormatterTest.cs
 System.ServiceModel.Syndication/Rss20FeedFormatterTest.cs


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
___________________________________________________________________
Name: svn:executable
   - *


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonReaderTest.cs
___________________________________________________________________
Name: svn:executable
   - *


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonWriterTest.cs
___________________________________________________________________
Name: svn:executable
   - *

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/ChangeLog
     2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/ChangeLog
     2008-02-13 12:53:55 UTC (rev 95574)
@@ -0,0 +1,3 @@
+2008-02-13  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * QueryStringConverterTest.cs : new test.


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/ChangeLog
___________________________________________________________________
Name: svn:executable
   + *

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/QueryStringConverterTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/QueryStringConverterTest.cs
   2008-02-13 12:49:26 UTC (rev 95573)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/QueryStringConverterTest.cs
   2008-02-13 12:53:55 UTC (rev 95574)
@@ -0,0 +1,213 @@
+//
+// QueryStringConverterTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 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.ComponentModel;
+using System.Globalization;
+using System.ServiceModel.Dispatcher;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+
+using CategoryAttribute = NUnit.Framework.CategoryAttribute;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class QueryStringConverterTest
+       {
+               QueryStringConverter c;
+
+               [SetUp]
+               public void Setup ()
+               {
+                       c = new QueryStringConverter ();
+               }
+
+               [Test]
+               public void CanConvert ()
+               {
+                       Assert.IsTrue (c.CanConvert (typeof (bool)), "#1");
+                       Assert.IsTrue (c.CanConvert (typeof (char)), "#2");
+                       Assert.IsTrue (c.CanConvert (typeof (double)), "#3");
+                       Assert.IsTrue (c.CanConvert (typeof (decimal)), "#4");
+                       Assert.IsTrue (c.CanConvert (typeof (float)), "#5");
+                       Assert.IsTrue (c.CanConvert (typeof (string)), "#6");
+                       Assert.IsTrue (c.CanConvert (typeof (int)), "#7");
+                       Assert.IsTrue (c.CanConvert (typeof (byte)), "#8");
+                       Assert.IsTrue (c.CanConvert (typeof (sbyte)), "#9");
+                       Assert.IsTrue (c.CanConvert (typeof (long)), "#10");
+                       Assert.IsTrue (c.CanConvert (typeof (ulong)), "#11");
+                       Assert.IsTrue (c.CanConvert (typeof (DateTime)), "#12");
+                       Assert.IsTrue (c.CanConvert (typeof (DateTimeOffset)), 
"#13");
+                       Assert.IsTrue (c.CanConvert (typeof (TimeSpan)), "#14");
+                       Assert.IsTrue (c.CanConvert (typeof (Guid)), "#15");
+                       Assert.IsFalse (c.CanConvert (typeof 
(XmlQualifiedName)), "#16");
+                       Assert.IsTrue (c.CanConvert (typeof (object)), "#17");
+                       Assert.IsFalse (c.CanConvert (typeof 
(QueryStringConverter)), "#18");
+                       // TypeConverterAttribute does not help it.
+                       Assert.IsFalse (c.CanConvert (typeof (MyConvertible)), 
"#19");
+               }
+
+               // ConvertStringToValue
+
+               [Test]
+               [ExpectedException (typeof (InvalidCastException))]
+               public void ConvertValueToStringInvalidCast ()
+               {
+                       c.ConvertValueToString ("ABC", typeof (char));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidCastException))]
+               public void ConvertValueToStringInvalidCast2 ()
+               {
+                       c.ConvertValueToString (123, typeof (string));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidCastException))]
+               public void ConvertValueToStringInvalidCast3 ()
+               {
+                       c.ConvertValueToString ("123", typeof (int));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidCastException))]
+               public void ConvertValueToStringInvalidCast4 ()
+               {
+                       c.ConvertValueToString (123.45, typeof (int));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidCastException))]
+               public void ConvertValueToStringInvalidCast5 ()
+               {
+                       // umm...
+                       c.ConvertValueToString (123, typeof (double));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConvertValueToStringNullToValueType ()
+               {
+                       c.ConvertValueToString (null, typeof (char));
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void ConvertValueToStringDbNull ()
+               {
+                       c.ConvertValueToString (DBNull.Value, typeof (DBNull));
+               }
+
+               [Test]
+               public void ConvertValueToStringNullToString ()
+               {
+                       Assert.IsNull (c.ConvertValueToString (null, typeof 
(string)));
+               }
+
+               [Test]
+               public void ConvertValueToString ()
+               {
+                       Assert.AreEqual ("A", c.ConvertValueToString ('A', 
typeof (char)), "#1");
+                       Assert.AreEqual ("}}}", c.ConvertValueToString ("}}}", 
typeof (string)), "#2");
+                       Assert.AreEqual ("123", c.ConvertValueToString (123.0, 
typeof (double)), "#3");
+               }
+
+               // ConvertStringToValue
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ConvertStringToValueInvalidCast ()
+               {
+                       c.ConvertStringToValue ("ABC", typeof (char));
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               [Category ("NotWorking")]
+               public void ConvertStringToValueInvalidCast2 ()
+               {
+                       c.ConvertStringToValue ("-123", typeof (uint));
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ConvertStringToValueInvalidCast4 ()
+               {
+                       c.ConvertStringToValue ("123.45", typeof (int));
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ConvertStringToValueNullToValueType ()
+               {
+                       // hmm, it passes.
+                       Assert.AreEqual (default (char), c.ConvertStringToValue 
(null, typeof (char)));
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void ConvertStringToValueDbNull ()
+               {
+                       c.ConvertStringToValue (null, typeof (DBNull));
+               }
+
+               [Test]
+               public void ConvertStringToValueNullToString ()
+               {
+                       Assert.IsNull (c.ConvertStringToValue (null, typeof 
(string)));
+               }
+
+               [Test]
+               public void ConvertStringToValue ()
+               {
+                       Assert.AreEqual ('A', c.ConvertStringToValue ("A", 
typeof (char)), "#1");
+                       Assert.AreEqual ("}}}", c.ConvertStringToValue ("}}}", 
typeof (string)), "#2");
+                       Assert.AreEqual (123.0, c.ConvertStringToValue 
("123.0", typeof (double)), "#3");
+                       Assert.AreEqual (123.0, c.ConvertStringToValue ("123", 
typeof (double)), "#4");
+               }
+
+               // Types
+
+               [TypeConverter (typeof (MyTypeConverter))]
+               class MyConvertible
+               {
+               }
+
+               class MyTypeConverter : TypeConverter
+               {
+                       public override object ConvertTo 
(ITypeDescriptorContext context, CultureInfo culture, object value, Type 
destinationType)
+                       {
+                               if (destinationType == typeof (string))
+                                       return "hogehoge";
+                               throw new Exception ();
+                       }
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/QueryStringConverterTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to