AssertExtensions.Throws<ArgumentOutOfRangeException>("scale", () => new Decimal(1, 2, 3, false, 29));
}
+ public static IEnumerable<object[]> Scale_TestData()
+ {
+ yield return new object[] { 10m, 0 };
+ yield return new object[] { 1m, 0 };
+ yield return new object[] { -1m, 0 };
+ yield return new object[] { 1.0m, 1 };
+ yield return new object[] { -1.0m, 1 };
+ yield return new object[] { 1.1m, 1 };
+ yield return new object[] { 1.00m, 2 };
+ yield return new object[] { 1.01m, 2 };
+ yield return new object[] { 1.0000000000000000000000000000m, 28};
+ }
+
+ [Theory]
+ [MemberData(nameof(Scale_TestData))]
+ public static void Scale(decimal value, byte expectedScale)
+ {
+ Assert.Equal(expectedScale, value.Scale);
+ }
+
+ [Theory]
+ [InlineData(new int[] { 1, 0, 0, 0 }, 0)] // 1
+ [InlineData(new int[] { 10, 0, 0, 65536 }, 1)] // 1.0
+ [InlineData(new int[] { 100, 0, 0, 131072 }, 2)] // 1.00
+ [InlineData(new int[] { 268435456, 1042612833, 542101086, 1835008 }, 28)] // 1.0000000000000000000000000000
+ [InlineData(new int[] { 10, 0, 0, -2147418112 }, 1)] // -1.0
+ public static void ScaleFromBits(int[] bits, byte expectedScale)
+ {
+ Assert.Equal(expectedScale, new decimal(bits).Scale);
+ }
+
public static IEnumerable<object[]> Add_Valid_TestData()
{
yield return new object[] { 1m, 1m, 2m };
Assert.Equal(0, result);
}
}
-
+
public static IEnumerable<object[]> Remainder_Valid_TestData()
{
decimal NegativeZero = new decimal(0, 0, 0, true, 0);