-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
NumberFormatInfoNumberDecimalDigits.cs
52 lines (46 loc) · 1.98 KB
/
NumberFormatInfoNumberDecimalDigits.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Licensed to the .NET Foundation under one or more agreements.
// 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 NumberFormatInfoNumberDecimalDigits
{
public static IEnumerable<object[]> NumberDecimalDigits_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, 2, 2 };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 2, 3 };
}
[Theory]
[MemberData(nameof(NumberDecimalDigits_TestData))]
public void NumberDecimalDigits_Get_ReturnsExpected(NumberFormatInfo format, int expectedNls, int expectedIcu)
{
int expected = PlatformDetection.IsNlsGlobalization ? expectedNls : expectedIcu;
Assert.Equal(expected, format.NumberDecimalDigits);
}
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(99)]
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_SetReadOnly_ThrowsInvalidOperationException()
{
Assert.Throws<InvalidOperationException>(() => NumberFormatInfo.InvariantInfo.NumberDecimalDigits = 1);
}
}
}