X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FTest%2FSystem.ComponentModel%2FByteConverterTests.cs;h=ca6a8cd78f49c00b3d28fe1cbe86c60c2d986375;hb=95dc4b45a2697b04c93fb8fdba2f4e48f1d8c2ee;hp=42381d551a97cd5e80cd082d6c62a400bf4c17e7;hpb=38bf36b08163b2fbeb3242d6e21f009c0f0fbdb3;p=mono.git diff --git a/mcs/class/System/Test/System.ComponentModel/ByteConverterTests.cs b/mcs/class/System/Test/System.ComponentModel/ByteConverterTests.cs index 42381d551a9..ca6a8cd78f4 100644 --- a/mcs/class/System/Test/System.ComponentModel/ByteConverterTests.cs +++ b/mcs/class/System/Test/System.ComponentModel/ByteConverterTests.cs @@ -64,6 +64,15 @@ namespace MonoTests.System.ComponentModel Assert.AreEqual (byte.MaxValue, converter.ConvertFrom (null, CultureInfo.InvariantCulture, "0XFF"), "#6"); } + [Test] + public void ConvertToString () + { + CultureInfo culture = new MyCultureInfo (); + NumberFormatInfo numberFormatInfo = (NumberFormatInfo) culture.GetFormat (typeof (NumberFormatInfo)); + + Assert.AreEqual (culture.NumberFormat.NegativeSign + "5", converter.ConvertToString (null, culture, -5)); + } + [Test] [ExpectedException (typeof (NotSupportedException))] public void ConvertFrom_Object () @@ -505,5 +514,39 @@ namespace MonoTests.System.ComponentModel Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#3"); } } + + [Serializable] + private sealed class MyCultureInfo : CultureInfo + { + internal MyCultureInfo () + : base ("en-US") + { + } + + public override object GetFormat (Type formatType) + { + if (formatType == typeof (NumberFormatInfo)) { + NumberFormatInfo nfi = (NumberFormatInfo) ((NumberFormatInfo) base.GetFormat (formatType)).Clone (); + + nfi.NegativeSign = "myNegativeSign"; + return NumberFormatInfo.ReadOnly (nfi); + } else { + return base.GetFormat (formatType); + } + } + +#if NET_2_0 +// adding this override in 1.x shows different result in .NET (it is ignored). +// Some compatibility kids might want to fix this issue. + public override NumberFormatInfo NumberFormat { + get { + NumberFormatInfo nfi = (NumberFormatInfo) base.NumberFormat.Clone (); + nfi.NegativeSign = "myNegativeSign"; + return nfi; + } + set { throw new NotSupportedException (); } + } +#endif + } } }