public bool NegTest3() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("NegTest3: ArgumentException is not thrown."); try { string testStr = ""; NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); nfi.CurrencyDecimalSeparator = testStr; TestLibrary.TestFramework.LogError("103.1", "ArgumentException is not thrown."); retVal = false; } catch (ArgumentException) { } catch (Exception e) { TestLibrary.TestFramework.LogError("103.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return(retVal); }
public void TestReadOnly() { NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); Assert.True(nfiReadOnly.IsReadOnly); }
public bool NegTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("NegTest2: InvalidOperationException is not thrown."); try { string testStr = "testStr"; NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); nfiReadOnly.CurrencyGroupSeparator = testStr; TestLibrary.TestFramework.LogError("102.1", "InvalidOperationException is not thrown."); retVal = false; } catch (InvalidOperationException) { } catch (Exception e) { TestLibrary.TestFramework.LogError("102.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return(retVal); }
/// <summary> /// Allows setting all field both for constructors and serialization methods. /// </summary> private void setAllFields(CurrencyIsoCode isoCode, string englishName, string nativeName, string symbol, int significantDecimalDigits, string decimalSeparator, string groupSeparator, int[] groupSizes, int positivePattern, int negativePattern, bool isObsolete, CharacterReference entity) { IsoCode = isoCode; EnglishName = englishName; Symbol = symbol; AlphabeticCode = IsoSymbol = isoCode.ToString(); SignificantDecimalDigits = significantDecimalDigits; NativeName = nativeName; DecimalSeparator = decimalSeparator; GroupSeparator = groupSeparator; GroupSizes = groupSizes; PositivePattern = positivePattern; NegativePattern = negativePattern; IsObsolete = isObsolete; Entity = entity; FormatInfo = NumberFormatInfo.ReadOnly(new NumberFormatInfo { CurrencySymbol = symbol, CurrencyDecimalDigits = significantDecimalDigits, CurrencyDecimalSeparator = decimalSeparator, CurrencyGroupSeparator = groupSeparator, CurrencyGroupSizes = groupSizes, CurrencyPositivePattern = positivePattern, CurrencyNegativePattern = negativePattern, NumberDecimalDigits = significantDecimalDigits, NumberDecimalSeparator = decimalSeparator, NumberGroupSeparator = groupSeparator, NumberGroupSizes = groupSizes, NumberNegativePattern = negativePattern.TranslateNegativePattern(), }); }
public bool PosTest1() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method ReadOnly ."); try { NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); if (nfiReadOnly.IsReadOnly != true) { TestLibrary.TestFramework.LogError("001.1", "Method ReadOnly Err ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return(retVal); }
public void ReadOnly(NumberFormatInfo format, bool expected) { Assert.Equal(expected, format.IsReadOnly); NumberFormatInfo readOnlyFormat = NumberFormatInfo.ReadOnly(format); Assert.True(readOnlyFormat.IsReadOnly); }
public void TestNullArgument() { NumberFormatInfo nfi = null; Assert.Throws <ArgumentNullException>(() => { NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); }); }
public static IEnumerable <object[]> ReadOnly_TestData() { yield return(new object[] { new NumberFormatInfo(), false }); yield return(new object[] { new CultureInfo("en-US").NumberFormat, false }); yield return(new object[] { NumberFormatInfo.InvariantInfo, true }); yield return(new object[] { NumberFormatInfo.ReadOnly(new CultureInfo("en-US").NumberFormat), true }); }
public void TestInvalidOperation() { NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); Assert.Throws <InvalidOperationException>(() => { nfiReadOnly.NumberDecimalDigits = 1; }); }
public void TestInvalidOperation() { NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); Assert.Throws <InvalidOperationException>(() => { nfiReadOnly.PercentPositivePattern = 1; }); }
public void NegTest2() { NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); Assert.Throws <InvalidOperationException>(() => { nfiReadOnly.CurrencyNegativePattern = 1; }); }
public void NegTest3() { NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); Assert.Throws <InvalidOperationException>(() => { nfiReadOnly.NumberGroupSizes = new int[] { 2, 3, 4 }; }); }
public void TestEmptyString() { string testStr = ""; NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); Assert.Throws <ArgumentException>(() => { nfi.CurrencyDecimalSeparator = testStr; }); }
public void TestInvalidOperation() { string testStr = "testStr"; NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); Assert.Throws <InvalidOperationException>(() => { nfiReadOnly.CurrencyDecimalSeparator = testStr; }); }
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)); } }
public bool NegTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("NegTest1: ArgumentNullException is not thrown."); try { NumberFormatInfo nfi = null; NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); TestLibrary.TestFramework.LogError("101.1", "ArgumentNullException is not thrown."); retVal = false; } catch (ArgumentNullException) { } catch (Exception e) { TestLibrary.TestFramework.LogError("101.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return(retVal); }
public void ReadOnly_ReadOnlyFormat() { NumberFormatInfo readOnlyFormat = NumberFormatInfo.ReadOnly(new NumberFormatInfo()); Assert.Same(readOnlyFormat, NumberFormatInfo.ReadOnly(readOnlyFormat)); }
public void ReadOnly_Null_ThrowsArgumentNullException() { AssertExtensions.Throws <ArgumentNullException>("nfi", () => NumberFormatInfo.ReadOnly(null)); }