// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Globalization.Tests
[Theory]
[MemberData(nameof(CurrencyDecimalDigits_TestData))]
- public void CurrencyDecimalDigits_Get(NumberFormatInfo format, int expectedWindows, int expectedIcu)
+ public void CurrencyDecimalDigits_Get_ReturnsExpected(NumberFormatInfo format, int expectedWindows, int expectedIcu)
{
- int expected = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? expectedWindows : expectedIcu;
+ int expected = PlatformDetection.IsWindows ? expectedWindows : expectedIcu;
Assert.Equal(expected, format.CurrencyDecimalDigits);
}
[InlineData(0)]
[InlineData(1)]
[InlineData(99)]
- public void CurrencyDecimalDigits_Set(int newCurrencyDecimalDigits)
+ public void CurrencyDecimalDigits_Set_GetReturnsExpected(int newCurrencyDecimalDigits)
{
NumberFormatInfo format = new NumberFormatInfo();
format.CurrencyDecimalDigits = newCurrencyDecimalDigits;
Assert.Equal(newCurrencyDecimalDigits, format.CurrencyDecimalDigits);
}
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(100)]
+ public void CurrencyDecimalDigits_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "CurrencyDecimalDigits", () => format.CurrencyDecimalDigits = value);
+ }
+
[Fact]
- public void CurrencyDecimalDigits_Set_Invalid()
+ public void CurrencyDecimalDigits_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("CurrencyDecimalDigits", () => new NumberFormatInfo().CurrencyDecimalDigits = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("CurrencyDecimalDigits", () => new NumberFormatInfo().CurrencyDecimalDigits = 100);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.CurrencyDecimalDigits = 2);
}
}
[Fact]
public void CurrencyDecimalSeparator_Set_Invalid()
{
- AssertExtensions.Throws<ArgumentNullException>("CurrencyDecimalSeparator", () => new NumberFormatInfo().CurrencyDecimalSeparator = null);
- AssertExtensions.Throws<ArgumentException>(null, () => new NumberFormatInfo().CurrencyDecimalSeparator = "");
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "CurrencyDecimalSeparator", () => format.CurrencyDecimalSeparator = null);
+ }
+
+ [Fact]
+ public void CurrencyDecimalSeparator_SetEmpty_ThrowsArgumentException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentException>("value", null, () => format.CurrencyDecimalSeparator = "");
+ }
+
+ [Fact]
+ public void CurrencyDecimalSeparator_SetReadOnly_ThrowsInvalidOperationException()
+ {
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.CurrencyDecimalSeparator = "string");
}
}
public class NumberFormatInfoCurrencyGroupSeparator
{
[Fact]
- public void CurrencyGroupSeparator_Get_InvariantInfo()
+ public void CurrencyGroupSeparator_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal(",", NumberFormatInfo.InvariantInfo.CurrencyGroupSeparator);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void CurrencyGroupSeparator_Set(string newCurrencyGroupSeparator)
+ public void CurrencyGroupSeparator_Set_GetReturnsExpected(string newCurrencyGroupSeparator)
{
NumberFormatInfo format = new NumberFormatInfo();
format.CurrencyGroupSeparator = newCurrencyGroupSeparator;
}
[Fact]
- public void CurrencyGroupSeparator_Set_Invalid()
+ public void CurrencyGroupSeparator_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "CurrencyGroupSeparator", () => format.CurrencyGroupSeparator = null);
+ }
+
+ [Fact]
+ public void CurrencyGroupSeparator_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("CurrencyGroupSeparator", () => new NumberFormatInfo().CurrencyGroupSeparator = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.CurrencyGroupSeparator = "string");
}
}
[Theory]
[MemberData(nameof(CurrencyGroupSizes_TestData))]
- public void CurrencyGroupSizes_Get(NumberFormatInfo format, int[] expected)
+ public void CurrencyGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected)
{
Assert.Equal(expected, format.CurrencyGroupSizes);
}
[InlineData(new int[] { 2, 3, 4 })]
[InlineData(new int[] { 2, 3, 4, 0 })]
[InlineData(new int[] { 0 })]
- public void CurrencyGroupSizes_Set(int[] newCurrencyGroupSizes)
+ public void CurrencyGroupSizes_Set_GetReturnsExpected(int[] newCurrencyGroupSizes)
{
NumberFormatInfo format = new NumberFormatInfo();
format.CurrencyGroupSizes = newCurrencyGroupSizes;
}
[Fact]
- public void CurrencyGroupSizes_Set_Invalid()
+ public void CurrencyGroupSizes_SetNull_ThrowsArgumentNullException()
{
- AssertExtensions.Throws<ArgumentNullException>("CurrencyGroupSizes", () => new NumberFormatInfo().CurrencyGroupSizes = null);
- AssertExtensions.Throws<ArgumentException>("CurrencyGroupSizes", () => new NumberFormatInfo().CurrencyGroupSizes = new int[] { -1, 1, 2 });
- AssertExtensions.Throws<ArgumentException>("CurrencyGroupSizes", () => new NumberFormatInfo().CurrencyGroupSizes = new int[] { 98, 99, 100 });
- AssertExtensions.Throws<ArgumentException>("CurrencyGroupSizes", () => new NumberFormatInfo().CurrencyGroupSizes = new int[] { 0, 1, 2 });
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "CurrencyGroupSizes", () => format.CurrencyGroupSizes = null);
+ }
+ [Theory]
+ [InlineData(new int[] { -1, 1, 2 })]
+ [InlineData(new int[] { 98, 99, 100 })]
+ [InlineData(new int[] { 0, 1, 2 })]
+ public void CurrencyGroupSizes_SetInvalid_ThrowsArgumentException(int[] value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentException>("value", "CurrencyGroupSizes", () => format.CurrencyGroupSizes = value);
+ }
+
+ [Fact]
+ public void CurrencyGroupSizes_SetReadOnly_ThrowsInvalidOperationException()
+ {
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.CurrencyGroupSizes = new int[] { 1, 2, 3 });
}
}
[Theory]
[MemberData(nameof(CurrencyNegativePattern_TestData))]
- public void CurrencyNegativePattern_Get(NumberFormatInfo format, int[] acceptablePatterns)
+ public void CurrencyNegativePattern_Get_ReturnsExpected(NumberFormatInfo format, int[] acceptablePatterns)
{
Assert.Contains(format.CurrencyNegativePattern, acceptablePatterns);
}
[InlineData("as")]
[InlineData("es-BO")]
[InlineData("fr-CA")]
- public void CurrencyNegativePattern_Get(string locale)
+ public void CurrencyNegativePattern_Get_ReturnsExpected(string locale)
{
CultureInfo culture;
try
[InlineData(0)]
[InlineData(1)]
[InlineData(15)]
- public void CurrencyNegativePattern_Set(int newCurrencyNegativePattern)
+ public void CurrencyNegativePattern_Set_GetReturnsExpected(int newCurrencyNegativePattern)
{
NumberFormatInfo format = new NumberFormatInfo();
format.CurrencyNegativePattern = newCurrencyNegativePattern;
Assert.Equal(newCurrencyNegativePattern, format.CurrencyNegativePattern);
}
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(16)]
+ public void CurrencyNegativePattern_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "CurrencyNegativePattern", () => format.CurrencyNegativePattern = -1);
+ }
+
[Fact]
- public void CurrencyNegativePattern_Set_Invalid()
+ public void CurrencyNegativePattern_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("CurrencyNegativePattern", () => new NumberFormatInfo().CurrencyNegativePattern = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("CurrencyNegativePattern", () => new NumberFormatInfo().CurrencyNegativePattern = 16);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.CurrencyNegativePattern = 1);
}
}
[Theory]
[MemberData(nameof(CurrencyPositivePattern_TestData))]
- public void CurrencyPositivePattern_Get(NumberFormatInfo format, int expected)
+ public void CurrencyPositivePattern_Get_ReturnsExpected(NumberFormatInfo format, int expected)
{
Assert.Equal(expected, format.CurrencyPositivePattern);
}
[InlineData(0)]
[InlineData(1)]
[InlineData(3)]
- public void CurrencyPositivePattern_Set(int newCurrencyPositivePattern)
+ public void CurrencyPositivePattern_Set_GetReturnsExpected(int newCurrencyPositivePattern)
{
NumberFormatInfo format = new NumberFormatInfo();
format.CurrencyPositivePattern = newCurrencyPositivePattern;
Assert.Equal(newCurrencyPositivePattern, format.CurrencyPositivePattern);
}
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(4)]
+ public void CurrencyPositivePattern_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "CurrencyPositivePattern", () => format.CurrencyPositivePattern = value);
+ }
+
[Fact]
- public void CurrencyPositivePattern_Set_Invalid()
+ public void CurrencyPositivePattern_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("CurrencyPositivePattern", () => new NumberFormatInfo().CurrencyPositivePattern = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("CurrencyPositivePattern", () => new NumberFormatInfo().CurrencyPositivePattern = 4);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.CurrencyPositivePattern = 1);
}
}
[InlineData("en-US", "$")]
[InlineData("en-GB", "\x00a3")] // pound
[InlineData("", "\x00a4")] // international
- public void CurrencySymbol_Get(string name, string expected)
+ public void CurrencySymbol_Get_ReturnsExpected(string name, string expected)
{
Assert.Equal(expected, CultureInfo.GetCultureInfo(name).NumberFormat.CurrencySymbol);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void CurrencySymbol_Set(string newCurrencySymbol)
+ public void CurrencySymbol_Set_GetReturnsExpected(string newCurrencySymbol)
{
NumberFormatInfo format = new NumberFormatInfo();
format.CurrencySymbol = newCurrencySymbol;
}
[Fact]
- public void CurrencySymbol_Set_Invalid()
+ public void CurrencySymbol_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "CurrencySymbol", () => format.CurrencySymbol = null);
+ }
+
+ [Fact]
+ public void CurrencySymbol_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("CurrencySymbol", () => new NumberFormatInfo().CurrencySymbol = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.CurrencySymbol = "");
}
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Collections.Generic;
using Xunit;
namespace System.Globalization.Tests
public class NumberFormatInfoNaNSymbol
{
[Fact]
- public void NaNSymbol_Get_InvariantInfo()
+ public void NaNSymbol_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal("NaN", NumberFormatInfo.InvariantInfo.NaNSymbol);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void NaNSymbol_Set(string newNaNSymbol)
+ public void NaNSymbol_Set_GetReturnsExpected(string newNaNSymbol)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NaNSymbol = newNaNSymbol;
}
[Fact]
- public void NaNSymbol_Set_Invalid()
+ public void NaNSymbol_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "NaNSymbol", () => format.NaNSymbol = null);
+ }
+
+ [Fact]
+ public void NaNSymbol_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("NaNSymbol", () => new NumberFormatInfo().NaNSymbol = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NaNSymbol = "");
}
}
[Theory]
[MemberData(nameof(NegativeInfinitySymbol_TestData))]
- public void NegativeInfinitySymbol_Get(NumberFormatInfo format)
+ public void NegativeInfinitySymbol_Get_ReturnsExpected(NumberFormatInfo format)
{
Assert.Equal(float.NegativeInfinity.ToString(format), format.NegativeInfinitySymbol);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void NegativeInfinitySymbol_Set(string newNegativeInfinitySymbol)
+ public void NegativeInfinitySymbol_Set_GetReturnsExpected(string newNegativeInfinitySymbol)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NegativeInfinitySymbol = newNegativeInfinitySymbol;
}
[Fact]
- public void NegativeInfinitySymbol_Set_Invalid()
+ public void NegativeInfinitySymbol_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "NegativeInfinitySymbol", () => format.NegativeInfinitySymbol = null);
+ }
+
+ [Fact]
+ public void NegativeInfinitySymbol_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("NegativeInfinitySymbol", () => new NumberFormatInfo().NegativeInfinitySymbol = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NegativeInfinitySymbol = "");
}
}
[Theory]
[MemberData(nameof(NegativeSign_TestData))]
- public void NegativeSign_Get(NumberFormatInfo format, string expected)
+ public void NegativeSign_Get_ReturnsExpected(NumberFormatInfo format, string expected)
{
Assert.Equal(expected, format.NegativeSign);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void NegativeSign_Set(string newNegativeSign)
+ public void NegativeSign_Set_GetReturnsExpected(string newNegativeSign)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NegativeSign = newNegativeSign;
}
[Fact]
- public void NegativeSign_Set_Invalid()
+ public void NegativeSign_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "NegativeSign", () => format.NegativeSign = null);
+ }
+
+ [Fact]
+ public void NegativeSign_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("NegativeSign", () => new NumberFormatInfo().NegativeSign = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NegativeSign = "");
}
}
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Globalization.Tests
[Theory]
[MemberData(nameof(NumberDecimalDigits_TestData))]
- public void NumberDecimalDigits_Get(NumberFormatInfo format, int expectedWindows, int expectedIcu)
+ public void NumberDecimalDigits_Get_ReturnsExpected(NumberFormatInfo format, int expectedWindows, int expectedIcu)
{
- int expected = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? expectedWindows : expectedIcu;
+ int expected = PlatformDetection.IsWindows ? expectedWindows : expectedIcu;
Assert.Equal(expected, format.NumberDecimalDigits);
}
[InlineData(0)]
[InlineData(1)]
[InlineData(99)]
- public void NumberDecimalDigits_Set(int newNumberDecimalDigits)
+ public void NumberDecimalDigits_Set_GetReturnsExpected(int newNumberDecimalDigits)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NumberDecimalDigits = newNumberDecimalDigits;
Assert.Equal(newNumberDecimalDigits, format.NumberDecimalDigits);
}
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(100)]
+ public void NumberDecimalDigits_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "NumberDecimalDigits", () => format.NumberDecimalDigits = value);
+ }
+
[Fact]
- public void NumberDecimalDigits_Set_Invalid()
+ public void NumberDecimalDigits_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("NumberDecimalDigits", () => new NumberFormatInfo().NumberDecimalDigits = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("NumberDecimalDigits", () => new NumberFormatInfo().NumberDecimalDigits = 100);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NumberDecimalDigits = 1);
}
}
public class NumberFormatInfoNumberDecimalSeparator
{
[Fact]
- public void NumberDecimalSeparator_Get_InvariantInfo()
+ public void NumberDecimalSeparator_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal(".", NumberFormatInfo.InvariantInfo.NumberDecimalSeparator);
}
[Theory]
[InlineData("string")]
[InlineData(" ")]
- public void NumberDecimalSeparator_Set(string newNumberDecimalSeparator)
+ public void NumberDecimalSeparator_Set_GetReturnsExpected(string newNumberDecimalSeparator)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NumberDecimalSeparator = newNumberDecimalSeparator;
}
[Fact]
- public void NumberDecimalSeparator_Set_Invalid()
+ public void NumberDecimalSeparator_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "NumberDecimalSeparator", () => format.NumberDecimalSeparator = null);
+ }
+
+ [Fact]
+ public void NumberDecimalSeparator_SetEmpty_ThrowsArgumentException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentException>("value", null, () => format.NumberDecimalSeparator = "");
+ }
+
+ [Fact]
+ public void NumberDecimalSeparator_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("NumberDecimalSeparator", () => new NumberFormatInfo().NumberDecimalSeparator = null);
- AssertExtensions.Throws<ArgumentException>(null, () => new NumberFormatInfo().NumberDecimalSeparator = "");
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NumberDecimalSeparator = "string");
}
}
public class NumberFormatInfoNumberGroupSeparator
{
[Fact]
- public void NumberGroupSeparator_Get_InvariantInfo()
+ public void NumberGroupSeparator_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal(",", NumberFormatInfo.InvariantInfo.NumberGroupSeparator);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void NumberGroupSeparator_Set(string newNumberGroupSeparator)
+ public void NumberGroupSeparator_Set_GetReturnsExpected(string newNumberGroupSeparator)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NumberGroupSeparator = newNumberGroupSeparator;
}
[Fact]
- public void NumberGroupSeparator_Set_Invalid()
+ public void NumberGroupSeparator_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "NumberGroupSeparator", () => format.NumberGroupSeparator = null);
+ }
+
+ [Fact]
+ public void NumberGroupSeparator_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("NumberGroupSeparator", () => new NumberFormatInfo().NumberGroupSeparator = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NumberGroupSeparator = "string");
}
}
[Theory]
[MemberData(nameof(NumberGroupSizes_TestData))]
- public void NumberGroupSizes_Get(NumberFormatInfo format, int[] expected)
+ public void NumberGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected)
{
Assert.Equal(expected, format.NumberGroupSizes);
}
[InlineData(new int[] { 2, 3, 4 })]
[InlineData(new int[] { 2, 3, 4, 0 })]
[InlineData(new int[] { 0 })]
- public void NumberGroupSizes_Set(int[] newNumberGroupSizes)
+ public void NumberGroupSizes_Set_GetReturnsExpected(int[] newNumberGroupSizes)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NumberGroupSizes = newNumberGroupSizes;
}
[Fact]
- public void NumberGroupSizes_Set_Invalid()
+ public void NumberGroupSizes_SetNull_ThrowsArgumentNullException()
{
- AssertExtensions.Throws<ArgumentNullException>("NumberGroupSizes", () => new NumberFormatInfo().NumberGroupSizes = null);
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "NumberGroupSizes", () => format.NumberGroupSizes = null);
+ }
- AssertExtensions.Throws<ArgumentException>("NumberGroupSizes", () => new NumberFormatInfo().NumberGroupSizes = new int[] { -1, 1, 2 });
- AssertExtensions.Throws<ArgumentException>("NumberGroupSizes", () => new NumberFormatInfo().NumberGroupSizes = new int[] { 98, 99, 100 });
- AssertExtensions.Throws<ArgumentException>("NumberGroupSizes", () => new NumberFormatInfo().NumberGroupSizes = new int[] { 0, 1, 2 });
+ [Theory]
+ [InlineData(new int[] { -1, 1, 2 })]
+ [InlineData(new int[] { 98, 99, 100 })]
+ [InlineData(new int[] { 0, 1, 2 })]
+ public void NumberGroupSizes_SetInvalid_ThrowsArgumentException(int[] value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentException>("value", "NumberGroupSizes", () => format.NumberGroupSizes = value);
+ }
+ [Fact]
+ public void NumberGroupSizes_SetReadOnly_ThrowsInvalidOperationException()
+ {
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NumberGroupSizes = new int[] { 1, 2, 3 });
}
}
[Theory]
[MemberData(nameof(NumberNegativePattern_TestData))]
- public void NumberNegativePattern_Get(NumberFormatInfo format, int expected)
+ public void NumberNegativePattern_Get_ReturnsExpected(NumberFormatInfo format, int expected)
{
Assert.Equal(expected, format.NumberNegativePattern);
}
[InlineData(0)]
[InlineData(1)]
[InlineData(4)]
- public void NumberNegativePattern_Set(int newNumberNegativePattern)
+ public void NumberNegativePattern_Set_GetReturnsExpected(int newNumberNegativePattern)
{
NumberFormatInfo format = new NumberFormatInfo();
format.NumberNegativePattern = newNumberNegativePattern;
Assert.Equal(newNumberNegativePattern, format.NumberNegativePattern);
}
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(5)]
+ public void NumberNegativePattern_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "NumberNegativePattern", () => format.NumberNegativePattern = value);
+ }
+
+
[Fact]
- public void NumberNegativePattern_Set_Invalid()
+ public void NumberNegativePattern_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("NumberNegativePattern", () => new NumberFormatInfo().NumberNegativePattern = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("NumberNegativePattern", () => new NumberFormatInfo().NumberNegativePattern = 5);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NumberNegativePattern = 1);
}
public class NumberFormatInfoPerMilleSymbol
{
[Fact]
- public void PerMilleSymbol_Get_InvariantInfo()
+ public void PerMilleSymbol_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal("\u2030", NumberFormatInfo.InvariantInfo.PerMilleSymbol);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void PerMilleSymbol_Set(string newPerMilleSymbol)
+ public void PerMilleSymbol_Set_GetReturnsExpected(string newPerMilleSymbol)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PerMilleSymbol = newPerMilleSymbol;
}
[Fact]
- public void PerMilleSymbol_Set_Invalid()
+ public void PerMilleSymbol_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "PerMilleSymbol", () => format.PerMilleSymbol = null);
+ }
+
+ [Fact]
+ public void PerMilleSymbol_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("PerMilleSymbol", () => new NumberFormatInfo().PerMilleSymbol = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PerMilleSymbol = "");
}
}
public class NumberFormatInfoPercentDecimalDigits
{
[Fact]
- public void PercentDecimalDigits_Get_InvariantInfo()
+ public void PercentDecimalDigits_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal(2, NumberFormatInfo.InvariantInfo.PercentDecimalDigits);
}
[InlineData(0)]
[InlineData(1)]
[InlineData(99)]
- public void PercentDecimalDigits_Set(int newPercentDecimalDigits)
+ public void PercentDecimalDigits_Set_GetReturnsExpected(int newPercentDecimalDigits)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PercentDecimalDigits = newPercentDecimalDigits;
Assert.Equal(newPercentDecimalDigits, format.PercentDecimalDigits);
}
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(100)]
+ public void PercentDecimalDigits_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "PercentDecimalDigits", () => format.PercentDecimalDigits = value);
+ }
+
+
[Fact]
- public void PercentDecimalDigits_Set_Invalid()
+ public void PercentDecimalDigits_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("PercentDecimalDigits", () => new NumberFormatInfo().PercentDecimalDigits = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("PercentDecimalDigits", () => new NumberFormatInfo().PercentDecimalDigits = 100);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PercentDecimalDigits = 1);
}
}
public class NumberFormatInfoPercentDecimalSeparator
{
[Fact]
- public void PercentDecimalSeparator_Get_InvariantInfo()
+ public void PercentDecimalSeparator_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal(".", NumberFormatInfo.InvariantInfo.PercentDecimalSeparator);
}
[Theory]
[InlineData("string")]
[InlineData(" ")]
- public void PercentDecimalSeparator_Set(string newPercentDecimalSeparator)
+ public void PercentDecimalSeparator_Set_GetReturnsExpected(string newPercentDecimalSeparator)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PercentDecimalSeparator = newPercentDecimalSeparator;
}
[Fact]
- public void PercentDecimalSeparator_Set_Invalid()
+ public void PercentDecimalSeparator_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "PercentDecimalSeparator", () => format.PercentDecimalSeparator = null);
+ }
+
+ [Fact]
+ public void PercentDecimalSeparator_SetEmpty_ThrowsArgumentException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentException>("value", null, () => format.PercentDecimalSeparator = "");
+ }
+
+ [Fact]
+ public void PercentDecimalSeparator_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("PercentDecimalSeparator", () => new NumberFormatInfo().PercentDecimalSeparator = null);
- AssertExtensions.Throws<ArgumentException>(null, () => new NumberFormatInfo().PercentDecimalSeparator = "");
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PercentDecimalSeparator = "string");
}
}
public class NumberFormatInfoPercentGroupSeparator
{
[Fact]
- public void PercentGroupSeparator_Get_InvariantInfo()
+ public void PercentGroupSeparator_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal(",", NumberFormatInfo.InvariantInfo.PercentGroupSeparator);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void PercentGroupSeparator_Set(string newPercentGroupSeparator)
+ public void PercentGroupSeparator_Set_GetReturnsExpected(string newPercentGroupSeparator)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PercentGroupSeparator = newPercentGroupSeparator;
}
[Fact]
- public void PercentGroupSeparator_Set_Invalid()
+ public void PercentGroupSeparator_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "PercentGroupSeparator", () => format.PercentGroupSeparator = null);
+ }
+
+ [Fact]
+ public void PercentGroupSeparator_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("PercentGroupSeparator", () => new NumberFormatInfo().PercentGroupSeparator = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PercentGroupSeparator = "string");
}
}
[Theory]
[MemberData(nameof(PercentGroupSizes_TestData))]
- public void PercentGroupSizes_Get(NumberFormatInfo format, int[] expected)
+ public void PercentGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected)
{
Assert.Equal(expected, format.PercentGroupSizes);
}
[InlineData(new int[] { 2, 3, 4 })]
[InlineData(new int[] { 2, 3, 4, 0 })]
[InlineData(new int[] { 0 })]
- public void PercentGroupSizes_Set(int[] newPercentGroupSizes)
+ public void PercentGroupSizes_Set_GetReturnsExpected(int[] newPercentGroupSizes)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PercentGroupSizes = newPercentGroupSizes;
}
[Fact]
- public void PercentGroupSizes_Set_Invalid()
+ public void PercentGroupSizes_SetNull_ThrowsArgumentNullException()
{
- AssertExtensions.Throws<ArgumentNullException>("PercentGroupSizes", () => new NumberFormatInfo().PercentGroupSizes = null);
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "PercentGroupSizes", () => format.PercentGroupSizes = null);
+ }
- AssertExtensions.Throws<ArgumentException>("PercentGroupSizes", () => new NumberFormatInfo().PercentGroupSizes = new int[] { -1, 1, 2 });
- AssertExtensions.Throws<ArgumentException>("PercentGroupSizes", () => new NumberFormatInfo().PercentGroupSizes = new int[] { 98, 99, 100 });
- AssertExtensions.Throws<ArgumentException>("PercentGroupSizes", () => new NumberFormatInfo().PercentGroupSizes = new int[] { 0, 1, 2 });
+ [Theory]
+ [InlineData(new int[] { -1, 1, 2 })]
+ [InlineData(new int[] { 98, 99, 100 })]
+ [InlineData(new int[] { 0, 1, 2 })]
+ public void PercentGroupSizes_SetInvalid_ThrowsArgumentException(int[] value)
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentException>("value", "PercentGroupSizes", () => format.PercentGroupSizes = value);
+ }
+ [Fact]
+ public void PercentGroupSizes_SetReadOnly_ThrowsInvalidOperationException()
+ {
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PercentGroupSizes = new int[] { 1, 2, 3 });
}
}
[Theory]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[MemberData(nameof(PercentNegativePattern_TestData))]
- public void PercentNegativePattern_Get(NumberFormatInfo format, int expected)
+ public void PercentNegativePattern_Get_ReturnsExpected(NumberFormatInfo format, int expected)
{
Assert.Equal(expected, format.PercentNegativePattern);
}
[Fact]
- public void PercentNegativePattern_Invariant_Get()
+ public void PercentNegativePattern_GetInvariant_ReturnsExpected()
{
Assert.Equal(0, NumberFormatInfo.InvariantInfo.PercentNegativePattern);
}
[InlineData(0)]
[InlineData(1)]
[InlineData(11)]
- public void PercentNegativePattern_Set(int newPercentNegativePattern)
+ public void PercentNegativePattern_Set_GetReturnsExpected(int newPercentNegativePattern)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PercentNegativePattern = newPercentNegativePattern;
Assert.Equal(newPercentNegativePattern, format.PercentNegativePattern);
}
- [Fact]
- public void PercentNegativePattern_Set_Invalid()
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(12)]
+ public void PercentNegativePattern_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("PercentNegativePattern", () => new NumberFormatInfo().PercentNegativePattern = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("PercentNegativePattern", () => new NumberFormatInfo().PercentNegativePattern = 12);
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "PercentNegativePattern", () => format.PercentNegativePattern = value);
+ }
+ [Fact]
+ public void PercentNegativePattern_SetReadOnly_ThrowsInvalidOperationException()
+ {
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PercentNegativePattern = 1);
}
}
[Theory]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[MemberData(nameof(PercentPositivePattern_TestData))]
- public void PercentPositivePattern_Get(NumberFormatInfo format, int expected)
+ public void PercentPositivePattern_Get_ReturnsExpected(NumberFormatInfo format, int expected)
{
Assert.Equal(expected, format.PercentPositivePattern);
}
[Fact]
- public void PercentPositivePattern_Invariant_Get()
+ public void PercentPositivePattern_GetInvariantInfo_ReturnsExpected()
{
Assert.Equal(0, NumberFormatInfo.InvariantInfo.PercentPositivePattern);
}
[InlineData(0)]
[InlineData(1)]
[InlineData(3)]
- public void PercentPositivePattern_Set(int newPercentPositivePattern)
+ public void PercentPositivePattern_Set_GetReturnsExpected(int newPercentPositivePattern)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PercentPositivePattern = newPercentPositivePattern;
Assert.Equal(newPercentPositivePattern, format.PercentPositivePattern);
}
- [Fact]
- public void PercentPositivePattern_Set_Invalid()
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(4)]
+ public void PercentPositivePattern_SetInvalid_ThrowsArgumentOutOfRangeException(int value)
{
- AssertExtensions.Throws<ArgumentOutOfRangeException>("PercentPositivePattern", () => new NumberFormatInfo().PercentPositivePattern = -1);
- AssertExtensions.Throws<ArgumentOutOfRangeException>("PercentPositivePattern", () => new NumberFormatInfo().PercentPositivePattern = 4);
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentOutOfRangeException>("value", "PercentPositivePattern", () => format.PercentPositivePattern = value);
+ }
+ [Fact]
+ public void PercentPositivePattern_SetReadOnly_ThrowsInvalidOperationException()
+ {
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PercentPositivePattern = 1);
}
}
[Theory]
[MemberData(nameof(PercentSymbol_TestData))]
- public void PercentSymbol_Get(NumberFormatInfo format, string expected)
+ public void PercentSymbol_Get_ReturnsExpected(NumberFormatInfo format, string expected)
{
Assert.Equal(expected, format.PercentSymbol);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void PercentSymbol_Set(string newPercentSymbol)
+ public void PercentSymbol_Set_GetReturnsExpected(string newPercentSymbol)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PercentSymbol = newPercentSymbol;
}
[Fact]
- public void PercentSymbol_Set_Invalid()
+ public void PercentSymbol_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "PercentSymbol", () => format.PercentSymbol = null);
+ }
+
+ [Fact]
+ public void PercentSymbol_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("PercentSymbol", () => new NumberFormatInfo().PercentSymbol = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PercentSymbol = "");
}
}
[Theory]
[MemberData(nameof(PositiveInfinitySymbol_TestData))]
- public void PositiveInfinitySymbol_Get(NumberFormatInfo format)
+ public void PositiveInfinitySymbol_Get_ReturnsExpected(NumberFormatInfo format)
{
Assert.Equal(float.PositiveInfinity.ToString(format), format.PositiveInfinitySymbol);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void PositiveInfinitySymbol_Set(string newPositiveInfinitySymbol)
+ public void PositiveInfinitySymbol_Set_GetReturnsExpected(string newPositiveInfinitySymbol)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PositiveInfinitySymbol = newPositiveInfinitySymbol;
}
[Fact]
- public void PositiveInfinitySymbol_Set_Invalid()
+ public void PositiveInfinitySymbol_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "PositiveInfinitySymbol", () => format.PositiveInfinitySymbol = null);
+ }
+
+ [Fact]
+ public void PositiveInfinitySymbol_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("PositiveInfinitySymbol", () => new NumberFormatInfo().PositiveInfinitySymbol = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PositiveInfinitySymbol = "");
}
}
[Theory]
[MemberData(nameof(PositiveSign_TestData))]
- public void PositiveSign_Get(NumberFormatInfo format, string expected)
+ public void PositiveSign_Get_ReturnsExpected(NumberFormatInfo format, string expected)
{
Assert.Equal(expected, format.PositiveSign);
}
[InlineData("string")]
[InlineData(" ")]
[InlineData("")]
- public void PositiveSign_Set(string newPositiveSign)
+ public void PositiveSign_Set_GetReturnsExpected(string newPositiveSign)
{
NumberFormatInfo format = new NumberFormatInfo();
format.PositiveSign = newPositiveSign;
}
[Fact]
- public void PositiveSign_Set_Invalid()
+ public void PositiveSign_SetNull_ThrowsArgumentNullException()
+ {
+ var format = new NumberFormatInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "PositiveSign", () => format.PositiveSign = null);
+ }
+
+ [Fact]
+ public void PositiveSign_SetReadOnly_ThrowsInvalidOperationException()
{
- AssertExtensions.Throws<ArgumentNullException>("PositiveSign", () => new NumberFormatInfo().PositiveSign = null);
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.PositiveSign = "");
}
}
public class StringInfoCtorTests
{
[Fact]
- public void Ctor_Empty()
+ public void Ctor_Default()
{
StringInfo stringInfo = new StringInfo();
Assert.Equal(string.Empty, stringInfo.String);
}
[Fact]
- public void Ctor_String_Null_ThrowsArgumentNullException()
+ public void Ctor_NullValue_ThrowsArgumentNullException()
{
- AssertExtensions.Throws<ArgumentNullException>("String", () => new StringInfo(null));
+ AssertExtensions.Throws<ArgumentNullException>("value", "String", () => new StringInfo(null));
}
}
}
[InlineData("")]
[InlineData("abc")]
[InlineData("\uD800\uDC00")]
- public void String_Set(string value)
+ public void String_Set_GetReturnsExpected(string value)
{
StringInfo stringInfo = new StringInfo();
stringInfo.String = value;
}
[Fact]
- public void String_Set_Invalid()
+ public void String_SetNull_ThrowsArgumentNullException()
{
- AssertExtensions.Throws<ArgumentNullException>("String", () => new StringInfo().String = null);
+ var stringInfo = new StringInfo();
+ AssertExtensions.Throws<ArgumentNullException>("value", "String", () => stringInfo.String = null);
}
}
}