Пример #1
0
        public void ParseWithNumberStylesShouldReturnOptionDecimalNoneWhenStringIsNotExpectedHexNumber()
        {
            // Arrange
            var s = "1.1";
            Option <decimal> expected = None;

            // Act
            var result = DecimalType.Parse(s, NumberStyles.HexNumber);

            // Assert
            result.Should().Be(expected);
        }
Пример #2
0
        public void ParseWithNumberStylesShouldReturnOptionDecimalNone()
        {
            // Arrange
            var s = "not a decimal";
            Option <decimal> expected = None;

            // Act
            var result = DecimalType.Parse(s, NumberStyles.AllowDecimalPoint);

            // Assert
            result.Should().Be(expected);
        }
Пример #3
0
        public void ParseShouldReturnOptionDecimalNone()
        {
            // Arrange
            var s = "not a decimal";
            Option <decimal> expected = None;

            // Act
            var result = DecimalType.Parse(s);

            // Assert
            result.Should().Be(expected);
        }
Пример #4
0
        public void ParseShouldReturnOptionDecimalSome()
        {
            // Arrange
            var s = "1";
            Option <decimal> expected = Some(1M);

            // Act
            var result = DecimalType.Parse(s);

            // Assert
            result.Should().Be(expected);
        }
Пример #5
0
        public void ParseWithNumberStylesAndFormatProviderShouldReturnOptionDecimalNone()
        {
            // Arrange
            var             s = "p1$234.4";
            IFormatProvider formatProvider = new NumberFormatInfo()
            {
                PositiveSign = "p"
            };
            Option <decimal> expected = None;

            // Act
            var result = DecimalType.Parse(s, NumberStyles.AllowDecimalPoint, formatProvider);

            // Assert
            result.Should().Be(expected);
        }
Пример #6
0
        public void ParseWithNumberStylesAndFormatProviderShouldReturnOptionDecimalSome()
        {
            // Arrange
            var             s = "p1.1";
            IFormatProvider formatProvider = new NumberFormatInfo()
            {
                PositiveSign = "p", NumberDecimalSeparator = "."
            };
            Option <decimal> expected = Some(1.1M);

            // Act
            var result = DecimalType.Parse(s, NumberStyles.Number, formatProvider);

            // Assert
            result.Should().Be(expected);
        }
Пример #7
0
        public void ParseWithFormatProviderShouldReturnOptionDecimalSome()
        {
            // Arrange
            var             s = "p1234";
            IFormatProvider formatProvider = new NumberFormatInfo()
            {
                PositiveSign = "p"
            };

            Option <decimal> expected = Some(1234M);

            // Act
            var result = DecimalType.Parse(s, formatProvider);

            // Assert
            result.Should().Be(expected);
        }
Пример #8
0
 public void Parse_Invalid()
 {
     Assert.Throws <ArgumentNullException>(() => DecimalType.Parse(null, null));
     Assert.Throws <FormatException>(() => DecimalType.Parse("abc", CultureInfo.InvariantCulture.NumberFormat));
 }
Пример #9
0
 public void Parse(string value, decimal expected)
 {
     Assert.Equal(expected, DecimalType.Parse(value, CultureInfo.InvariantCulture.NumberFormat));
 }