Ejemplo n.º 1
0
        public void TurkishI_Is_Differently_LowerUpperCased_In_Turkish_Culture()
        {
            RemoteExecutorForUap.Invoke(() =>
            {
                var turkish  = new CultureInfo("tr-TR");
                string input = "I\u0131\u0130i";

                Regex[] cultInvariantRegex = Create(input, CultureInfo.InvariantCulture, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                Regex[] turkishRegex       = Create(input, turkish, RegexOptions.IgnoreCase);

                // same input and regex does match so far so good
                Assert.All(cultInvariantRegex, rex => Assert.True(rex.IsMatch(input)));

                // when the Regex was created with a turkish locale the lower cased turkish version will
                // no longer match the input string which contains upper and lower case iiiis hence even the input string
                // will no longer match
                Assert.All(turkishRegex, rex => Assert.False(rex.IsMatch(input)));

                // Now comes the tricky part depending on the use locale in ToUpper the results differ
                // Hence the regular expression will not match if different locales were used
                Assert.All(cultInvariantRegex, rex => Assert.True(rex.IsMatch(input.ToLowerInvariant())));
                Assert.All(cultInvariantRegex, rex => Assert.False(rex.IsMatch(input.ToLower(turkish))));

                Assert.All(turkishRegex, rex => Assert.False(rex.IsMatch(input.ToLowerInvariant())));
                Assert.All(turkishRegex, rex => Assert.True(rex.IsMatch(input.ToLower(turkish))));
            }).Dispose();
        }
Ejemplo n.º 2
0
        public static void CommaDecimalExtremaAndInvalidValuesInvariantBoth(Type type, string min, string max, string value)
        {
            RemoteExecutorForUap.Invoke((t, m1, m2, v) =>
            {
                using (new ThreadCultureChange("en-US"))
                {
                    var range = new RangeAttribute(Type.GetType(t), m1, m2)
                    {
                        ConvertValueInInvariantCulture = true,
                        ParseLimitsInInvariantCulture  = true
                    };
                    AssertExtensions.Throws <ArgumentException>("value", () => range.IsValid(v));
                }

                using (new ThreadCultureChange("fr-FR"))
                {
                    var range = new RangeAttribute(Type.GetType(t), m1, m2)
                    {
                        ConvertValueInInvariantCulture = true,
                        ParseLimitsInInvariantCulture  = true
                    };
                    AssertExtensions.Throws <ArgumentException>("value", () => range.IsValid(v));
                }
            }, type.ToString(), min, max, value).Dispose();
        }
        public void LocaleOnRootWithoutIsDataSet()
        {
            RemoteExecutorForUap.Invoke(() =>
            {
                using (new ThreadCultureChange("fi-FI"))
                {
                    string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
    <xs:element name='Root' msdata:Locale='ja-JP'>
        <xs:complexType>
            <xs:sequence>
                <xs:element name='Child' type='xs:string' />
            </xs:sequence>
            <xs:attribute name='Attr' type='xs:integer' />
        </xs:complexType>
    </xs:element>
</xs:schema>";

                    var ds = new DataSet();
                    ds.ReadXmlSchema(new StringReader(xs));
                    DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
                    Assert.Equal("fi-FI", ds.Locale.Name); // DataSet's Locale comes from current thread
                    DataTable dt = ds.Tables[0];
                    DataSetAssertion.AssertDataTable("dt", dt, "Root", 2, 0, 0, 0, 0, 0);
                    Assert.Equal("ja-JP", dt.Locale.Name); // DataTable's Locale comes from msdata:Locale
                    DataSetAssertion.AssertDataColumn("col1", dt.Columns[0], "Attr", true, false, 0, 1, "Attr", MappingType.Attribute, typeof(long), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
                    DataSetAssertion.AssertDataColumn("col2", dt.Columns[1], "Child", false, false, 0, 1, "Child", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
                }
            }).Dispose();
        }
Ejemplo n.º 4
0
        public static void ConvertFrom_InstanceDescriptor()
        {
            RemoteExecutorForUap.Invoke(() =>
            {
                using (new ThreadCultureChange("fr-FR"))
                {
                    DateTime testDateAndTime = DateTime.UtcNow;
                    ConstructorInfo ctor     = typeof(DateTime).GetConstructor(new Type[]
                    {
                        typeof(int), typeof(int), typeof(int), typeof(int),
                        typeof(int), typeof(int), typeof(int)
                    });

                    InstanceDescriptor descriptor = new InstanceDescriptor(ctor, new object[]
                    {
                        testDateAndTime.Year, testDateAndTime.Month, testDateAndTime.Day, testDateAndTime.Hour,
                        testDateAndTime.Minute, testDateAndTime.Second, testDateAndTime.Millisecond
                    });

                    const string format = "dd MMM yyyy hh:mm";
                    object o            = s_converter.ConvertFrom(descriptor);
                    Assert.Equal(testDateAndTime.ToString(format), ((DateTime)o).ToString(format));
                }
            }).Dispose();
        }
Ejemplo n.º 5
0
        public void Properties()
        {
            RemoteExecutorForUap.Invoke(() =>
            {
                using (new ThreadCultureChange("en-AU"))
                {
                    var one = new SqlString("First TestString");

                    // CompareInfo
                    Assert.Equal(3081, one.CompareInfo.LCID);

                    // CultureInfo
                    Assert.Equal(3081, one.CultureInfo.LCID);

                    // LCID
                    Assert.Equal(3081, one.LCID);

                    // IsNull
                    Assert.True(!one.IsNull);
                    Assert.True(SqlString.Null.IsNull);

                    // SqlCompareOptions
                    Assert.Equal("IgnoreCase, IgnoreKanaType, IgnoreWidth", one.SqlCompareOptions.ToString());

                    // Value
                    Assert.Equal("First TestString", one.Value);
                }
            }).Dispose();
        }
Ejemplo n.º 6
0
        public static void DotDecimalExtremaAndInvalidValuesInvariantBoth(Type type, string min, string max, string value)
        {
            RemoteExecutorForUap.Invoke((t, m1, m2, v) =>
            {
                using (new ThreadCultureChange("en-US"))
                {
                    Assert.False(
                        new RangeAttribute(Type.GetType(t), m1, m2)
                    {
                        ConvertValueInInvariantCulture = true,
                        ParseLimitsInInvariantCulture  = true
                    }.IsValid(v));
                }

                using (new ThreadCultureChange("fr-FR"))
                {
                    Assert.False(
                        new RangeAttribute(Type.GetType(t), m1, m2)
                    {
                        ConvertValueInInvariantCulture = true,
                        ParseLimitsInInvariantCulture  = true
                    }.IsValid(v));
                }
            }, type.ToString(), min, max, value).Dispose();
        }
Ejemplo n.º 7
0
        public static void ConvertTo_WithContext()
        {
            RemoteExecutorForUap.Invoke(() =>
            {
                using (new ThreadCultureChange("pl-PL"))
                {
                    Assert.Throws <ArgumentNullException>(
                        () => s_converter.ConvertTo(s_context, null, c_conversionInputValue, null));

                    Assert.Throws <NotSupportedException>(
                        () => s_converter.ConvertTo(s_context, null, c_conversionInputValue, typeof(int)));

                    object o = s_converter.ConvertTo(s_context, null, c_conversionInputValue, typeof(string));
                    VerifyConversionToString(o);

                    o = s_converter.ConvertTo(
                        s_context, CultureInfo.CurrentCulture, c_conversionInputValue, typeof(string));
                    VerifyConversionToString(o);

                    o = s_converter.ConvertTo(
                        s_context, CultureInfo.InvariantCulture, c_conversionInputValue, typeof(string));
                    VerifyConversionToString(o);

                    string s = s_converter.ConvertTo(
                        s_context, CultureInfo.InvariantCulture, new FormattableClass(), typeof(string)) as string;
                    Assert.NotNull(s);
                    Assert.Equal(FormattableClass.Token, s);
                }
            }).Dispose();
        }
 public void CurrentInfo_Subclass_OverridesNumberFormat()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange(new CultureInfoSubclassOverridesNumberFormat("en-US")))
         {
             Assert.Same(CultureInfoSubclassOverridesNumberFormat.CustomFormat, NumberFormatInfo.CurrentInfo);
         }
     }).Dispose();
 }
Ejemplo n.º 9
0
 [OuterLoop("May fail on machines with multiple language packs installed")] // https://github.com/dotnet/corefx/issues/39177
 public void DisplayName(string name, string expected)
 {
     RemoteExecutorForUap.Invoke((string _name, string _expected) =>
     {
         using (new ThreadCultureChange(_name))
         {
             Assert.Equal(_expected, new RegionInfo(_name).DisplayName);
         }
     }, name, expected).Dispose();
 }
 public void DesignerOptionConverter_ConvertToString_ReturnsExpected()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange(null, CultureInfo.InvariantCulture))
         {
             TypeConverter converter = TypeDescriptor.GetConverter(typeof(DesignerOptionService.DesignerOptionCollection));
             Assert.Equal("(Collection)", converter.ConvertToString(null));
         }
     }).Dispose();
 }
 public void CurrentInfo_CustomCulture(CultureInfo newCurrentCulture)
 {
     RemoteExecutorForUap.Invoke((cultureName) =>
     {
         var newCulture = CultureInfo.GetCultureInfo(cultureName);
         using (new ThreadCultureChange(newCulture))
         {
             Assert.Same(newCulture.NumberFormat, NumberFormatInfo.CurrentInfo);
         }
     }, newCurrentCulture.Name).Dispose();
 }
Ejemplo n.º 12
0
 public void Match_SpecialUnicodeCharacters_enUS()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange("en-US"))
         {
             Match("\u0131", "\u0049", RegexOptions.IgnoreCase, 0, 1, false, string.Empty);
             Match("\u0131", "\u0069", RegexOptions.IgnoreCase, 0, 1, false, string.Empty);
         }
     }).Dispose();
 }
        public void XsdSchemaSerializationIgnoresLocale()
        {
            RemoteExecutorForUap.Invoke(() =>
            {
                var serializer = new BinaryFormatter();
                var table      = new DataTable();
                table.Columns.Add(new DataColumn("RowID", typeof(int))
                {
                    AutoIncrement     = true,
                    AutoIncrementSeed = -1,     // These lines produce attributes within the schema portion of the underlying XML representation of the DataTable with the values "-1" and "-2".
                    AutoIncrementStep = -2,
                });
                table.Columns.Add("Value", typeof(string));
                table.Rows.Add(1, "Test");
                table.Rows.Add(2, "Data");

                var buffer = new MemoryStream();
                using (new ThreadCultureChange(new CultureInfo("en-US")
                {
                    NumberFormat = new NumberFormatInfo()
                    {
                        NegativeSign = "()"
                    }
                }))
                {
                    // Before serializing, update the culture to use a weird negative number format. This test is ensuring that this is ignored.
                    serializer.Serialize(buffer, table);
                }

                // The raw serialized data now contains an embedded XML schema. We need to verify that this embedded schema used "-1" for the numeric value
                // negative 1, instead of "()1" as indicated by the current culture.

                string rawSerializedData = System.Text.Encoding.ASCII.GetString(buffer.ToArray());

                const string SchemaStartTag = "<xs:schema";
                const string SchemaEndTag   = "</xs:schema>";

                int schemaStart = rawSerializedData.IndexOf(SchemaStartTag);
                int schemaEnd   = rawSerializedData.IndexOf(SchemaEndTag);
                Assert.True(schemaStart >= 0);
                Assert.True(schemaEnd > schemaStart);
                Assert.True(rawSerializedData.IndexOf("<xs:schema", schemaStart + 1) < 0);

                schemaEnd += SchemaEndTag.Length;

                string rawSchemaXML = rawSerializedData.Substring(
                    startIndex: schemaStart,
                    length: schemaEnd - schemaStart);
                Assert.Contains(@"AutoIncrementSeed=""-1""", rawSchemaXML);
                Assert.Contains(@"AutoIncrementStep=""-2""", rawSchemaXML);
                Assert.DoesNotContain("()1", rawSchemaXML);
                Assert.DoesNotContain("()2", rawSchemaXML);
            }).Dispose();
        }
Ejemplo n.º 14
0
 public void Chr_CharCodeOutOfRange_ThrowsNotSupportedException(int charCode)
 {
     RemoteExecutorForUap.Invoke(charCodeInner =>
     {
         Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
         using (new ThreadCultureChange("en-US")) // Strings.Chr doesn't fail on these inputs for all code pages, e.g. 949
         {
             AssertExtensions.Throws <ArgumentException>(null, () => Strings.Chr(int.Parse(charCodeInner, CultureInfo.InvariantCulture)));
         }
     }, charCode.ToString(CultureInfo.InvariantCulture)).Dispose();
 }
Ejemplo n.º 15
0
 public void NameReturnsUnknownForHandle()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange(CultureInfo.InvariantCulture))
             using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite))
                 using (FileStream fsh = new FileStream(fs.SafeFileHandle, FileAccess.ReadWrite))
                 {
                     Assert.Equal("[Unknown]", fsh.Name);
                 }
     }).Dispose();
 }
Ejemplo n.º 16
0
 public void CurrentRegion()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange("en-US"))
         {
             RegionInfo ri = new RegionInfo(new RegionInfo(CultureInfo.CurrentCulture.Name).TwoLetterISORegionName);
             Assert.True(RegionInfo.CurrentRegion.Equals(ri) || RegionInfo.CurrentRegion.Equals(new RegionInfo(CultureInfo.CurrentCulture.Name)));
             Assert.Same(RegionInfo.CurrentRegion, RegionInfo.CurrentRegion);
         }
     }).Dispose();
 }
Ejemplo n.º 17
0
        public void ConvertFrom_DestinationType_Success()
        {
            Assert.All(ConvertFromTestData(), convertTest =>
            {
                // We need to duplicate this test code as RemoteInvoke can't
                // create "this" as the declaring type is an abstract class.
                if (convertTest.RemoteInvokeCulture == null)
                {
                    if (convertTest.Source != null)
                    {
                        Assert.Equal(convertTest.CanConvert, Converter.CanConvertFrom(convertTest.Context, convertTest.Source.GetType()));
                    }

                    if (convertTest.NetCoreExceptionType == null)
                    {
                        object actual = Converter.ConvertFrom(convertTest.Context, convertTest.Culture, convertTest.Source);
                        Assert.Equal(convertTest.Expected, actual);
                    }
                    else
                    {
                        AssertExtensions.Throws(convertTest.NetCoreExceptionType, convertTest.NetFrameworkExceptionType, () => Converter.ConvertFrom(convertTest.Context, convertTest.Culture, convertTest.Source));
                    }
                }
                else
                {
                    RemoteExecutorForUap.Invoke((typeName, testString) =>
                    {
                        // Deserialize the current test.
                        TypeConverterTestBase testBase = (TypeConverterTestBase)Activator.CreateInstance(Type.GetType(typeName));
                        ConvertTest test = ConvertTest.FromSerializedString(testString);

                        using (new ThreadCultureChange(test.RemoteInvokeCulture))
                        {
                            if (test.Source != null)
                            {
                                Assert.Equal(test.CanConvert, testBase.Converter.CanConvertFrom(test.Context, test.Source.GetType()));
                            }

                            if (test.NetCoreExceptionType == null)
                            {
                                object actual = testBase.Converter.ConvertFrom(test.Context, test.Culture, test.Source);
                                Assert.Equal(test.Expected, actual);
                            }
                            else
                            {
                                AssertExtensions.Throws(test.NetCoreExceptionType, test.NetFrameworkExceptionType, () => testBase.Converter.ConvertFrom(test.Context, test.Culture, test.Source));
                            }
                        }
                    }, this.GetType().AssemblyQualifiedName, convertTest.GetSerializedString()).Dispose();
                }
            });
        }
Ejemplo n.º 18
0
 public void JsonValue_Parse_Double(string json, double expected)
 {
     RemoteExecutorForUap.Invoke((jsonInner, expectedInner) =>
     {
         foreach (string culture in new[] { "en", "fr", "de" })
         {
             using (new ThreadCultureChange(culture))
             {
                 Assert.Equal(double.Parse(expectedInner, CultureInfo.InvariantCulture), (double)JsonValue.Parse(jsonInner));
             }
         }
     }, json, expected.ToString("R", CultureInfo.InvariantCulture)).Dispose();
 }
Ejemplo n.º 19
0
 public static void Test_ToString_NotNetFramework()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange(CultureInfo.InvariantCulture))
         {
             foreach (object[] testdata in ToString_TestData_NotNetFramework())
             {
                 ToString((double)testdata[0], (string)testdata[1], (IFormatProvider)testdata[2], (string)testdata[3]);
             }
         }
     }).Dispose();
 }
 public void TestSettingThreadCultures()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         var culture = new CultureInfo("ja-JP");
         using (new ThreadCultureChange(culture))
         {
             var dt = new DateTime(2014, 3, 14, 3, 14, 0);
             Assert.Equal(dt.ToString(), dt.ToString(culture));
             Assert.Equal(dt.ToString(), dt.ToString(culture.DateTimeFormat));
         }
     }).Dispose();
 }
Ejemplo n.º 21
0
 public static void Invariant_DutchCulture_FormatsDoubleBasedOnInvariantCulture()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange("nl"))
         {
             double d        = 123.456; // would be 123,456 in Dutch
             string expected = string.Format(CultureInfo.InvariantCulture, "Invariant culture is used {0}", d);
             string actual   = FormattableString.Invariant($"Invariant culture is used {d}");
             Assert.Equal(expected, actual);
         }
     }).Dispose();
 }
Ejemplo n.º 22
0
 public static void IFormattableToString_UsesSuppliedFormatProvider()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange("nl"))
         {
             double d        = 123.456; // would be 123,456 in Dutch
             string expected = string.Format(CultureInfo.InvariantCulture, "Invariant culture is used {0}", d);
             string actual   = ((IFormattable)((FormattableString)$"Invariant culture is used {d}")).ToString(null, CultureInfo.InvariantCulture);
             Assert.Equal(expected, actual);
         }
     }).Dispose();
 }
Ejemplo n.º 23
0
        public static void RunParseToStringTests(CultureInfo culture)
        {
            RemoteExecutorForUap.Invoke((cultureName) =>
            {
                byte[] tempByteArray1 = new byte[0];

                using (new ThreadCultureChange(cultureName))
                {
                    //default style
                    VerifyDefaultParse(s_random);

                    //single NumberStyles
                    VerifyNumberStyles(NumberStyles.None, s_random);
                    VerifyNumberStyles(NumberStyles.AllowLeadingWhite, s_random);
                    VerifyNumberStyles(NumberStyles.AllowTrailingWhite, s_random);
                    VerifyNumberStyles(NumberStyles.AllowLeadingSign, s_random);
                    VerifyNumberStyles(NumberStyles.AllowTrailingSign, s_random);
                    VerifyNumberStyles(NumberStyles.AllowParentheses, s_random);
                    VerifyNumberStyles(NumberStyles.AllowDecimalPoint, s_random);
                    VerifyNumberStyles(NumberStyles.AllowThousands, s_random);
                    VerifyNumberStyles(NumberStyles.AllowExponent, s_random);
                    VerifyNumberStyles(NumberStyles.AllowCurrencySymbol, s_random);
                    VerifyNumberStyles(NumberStyles.AllowHexSpecifier, s_random);

                    //composite NumberStyles
                    VerifyNumberStyles(NumberStyles.Integer, s_random);
                    VerifyNumberStyles(NumberStyles.HexNumber, s_random);
                    VerifyNumberStyles(NumberStyles.Number, s_random);
                    VerifyNumberStyles(NumberStyles.Float, s_random);
                    VerifyNumberStyles(NumberStyles.Currency, s_random);
                    VerifyNumberStyles(NumberStyles.Any, s_random);

                    //invalid number style
                    // ******InvalidNumberStyles
                    NumberStyles invalid = (NumberStyles)0x7c00;
                    AssertExtensions.Throws <ArgumentException>(null, () =>
                    {
                        BigInteger.Parse("1", invalid).ToString("d");
                    });
                    AssertExtensions.Throws <ArgumentException>(null, () =>
                    {
                        BigInteger junk;
                        BigInteger.TryParse("1", invalid, null, out junk);
                        Assert.Equal("1", junk.ToString("d"));
                    });

                    //FormatProvider tests
                    RunFormatProviderParseStrings();
                }
            }, culture.ToString()).Dispose();
        }
 public static void ConvertTo_WithContext()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange(null, CultureInfo.InvariantCulture))
         {
             ConvertTo_WithContext(new object[1, 3]
             {
                 { "any string", "(Text)", null }
             },
                                   new MultilineStringConverter());
         }
     }).Dispose();
 }
 public static void CurrentCulture_DutchCulture_FormatsDoubleBasedOnCurrentCulture()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         var dutchCulture = new CultureInfo("nl");
         using (new ThreadCultureChange(dutchCulture))
         {
             double d        = 123.456;
             string expected = string.Format(dutchCulture, "Dutch decimal separator is comma {0}", d);
             string actual   = FormattableString.CurrentCulture($"Dutch decimal separator is comma {d}");
             Assert.Equal(expected, actual);
         }
     }).Dispose();
 }
Ejemplo n.º 26
0
 [InlineData(1.123456789e-28)]     // Values around the smallest positive decimal value
 public void JsonValue_Parse_Double_ViaJsonPrimitive(double number)
 {
     RemoteExecutorForUap.Invoke(numberText =>
     {
         double numberInner = double.Parse(numberText, CultureInfo.InvariantCulture);
         foreach (string culture in new[] { "en", "fr", "de" })
         {
             using (new ThreadCultureChange(culture))
             {
                 Assert.Equal(numberInner, (double)JsonValue.Parse(new JsonPrimitive(numberInner).ToString()));
             }
         }
     }, number.ToString("R", CultureInfo.InvariantCulture)).Dispose();
 }
Ejemplo n.º 27
0
 public static void ConvertTo_WithContext()
 {
     RemoteExecutorForUap.Invoke(() =>
     {
         using (new ThreadCultureChange(CultureInfo.InvariantCulture))
         {
             ConvertTo_WithContext(new object[2, 3]
             {
                 { typeof(char), "System.Char", null },       // the base class is not verifying if this type is not in the list
                 { null, "(none)", CultureInfo.InvariantCulture }
             },
                                   TypeListConverterTests.s_converter);
         }
     }).Dispose();
 }
Ejemplo n.º 28
0
        public void Asc_Chr_DoubleByte(int charCode, int expected)
        {
            RemoteExecutorForUap.Invoke((charCodeString, expectedString) =>
            {
                int charCode = int.Parse(charCodeString);
                int expected = int.Parse(expectedString);

                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                using (new ThreadCultureChange("ko-KR"))
                {
                    Assert.Equal(949, CultureInfo.CurrentCulture.TextInfo.ANSICodePage);
                    Assert.Equal(expected, (ushort)Strings.Asc(Strings.Chr(charCode)));
                }
            }, charCode.ToString(), expected.ToString()).Dispose();
        }
Ejemplo n.º 29
0
        public static void ParseCommaSeparatorInvariantExtremaInCommaSeparatorCultures(Type type, string min, string max)
        {
            RemoteExecutorForUap.Invoke((t, m1, m2) =>
            {
                using (new ThreadCultureChange("en-US"))
                {
                    var range = new RangeAttribute(Type.GetType(t), m1, m2);
                    AssertExtensions.Throws <ArgumentException>("value", () => range.IsValid(null));
                }

                using (new ThreadCultureChange("fr-FR"))
                {
                    Assert.True(new RangeAttribute(Type.GetType(t), m1, m2).IsValid(null));
                }
            }, type.ToString(), min, max).Dispose();
        }
Ejemplo n.º 30
0
        public static void DotDecimalExtremaAndInvalidValues(Type type, string min, string max, string value)
        {
            RemoteExecutorForUap.Invoke((t, m1, m2, v) =>
            {
                using (new ThreadCultureChange("en-US"))
                {
                    Assert.False(new RangeAttribute(Type.GetType(t), m1, m2).IsValid(v));
                }

                using (new ThreadCultureChange("fr-FR"))
                {
                    var range = new RangeAttribute(Type.GetType(t), m1, m2);
                    AssertExtensions.Throws <ArgumentException>("value", () => range.IsValid(v));
                }
            }, type.ToString(), min, max, value).Dispose();
        }