microsoft/healthcare-shared-components
Publicmirrored from https://github.com/microsoft/healthcare-shared-componentsAvailable
src/Microsoft.Health.Core.UnitTests/Extensions/DecimalExtensionsTests.cs
29lines · modecode
| 1 | // ------------------------------------------------------------------------------------------------- |
| 2 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. |
| 4 | // ------------------------------------------------------------------------------------------------- |
| 5 | |
| 6 | using Xunit; |
| 7 | |
| 8 | namespace Microsoft.Health.Core.Extensions.UnitTests |
| 9 | { |
| 10 | public class DecimalExtensionsTests |
| 11 | { |
| 12 | [Theory] |
| 13 | [InlineData("100", ".5")] |
| 14 | [InlineData("100.0", ".05")] |
| 15 | [InlineData("100.00", ".005")] |
| 16 | [InlineData("100.000", ".0005")] |
| 17 | [InlineData("100.010", ".0005")] |
| 18 | [InlineData("100.0000", ".00005")] |
| 19 | [InlineData("100.00000", ".000005")] |
| 20 | [InlineData("100.12345", ".000005")] |
| 21 | [InlineData(".1234567890123456789012345678", "0")] |
| 22 | public void GivenADecimal_WhenGetPrecisionModifierIsCalled_ThenCorrectDecimalIsReturned(string input, string expected) |
| 23 | { |
| 24 | var inputDecimal = decimal.Parse(input); |
| 25 | var expectedDecimal = decimal.Parse(expected); |
| 26 | Assert.Equal(expectedDecimal, inputDecimal.GetPrescisionModifier()); |
| 27 | } |
| 28 | } |
| 29 | } |