示例#1
0
        public void ParseWithNumberStylesShouldReturnOptionFloatNoneWhenStringIsNotExpectedHexNumber()
        {
            // Arrange
            var            s        = "1.0";
            Option <float> expected = None;

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

            // Assert
            result.Should().Be(expected);
        }
示例#2
0
        public void ParseWithNumberStylesShouldReturnOptionFloatNone()
        {
            // Arrange
            var            s        = "not a float";
            Option <float> expected = None;

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

            // Assert
            result.Should().Be(expected);
        }
示例#3
0
        public void ParseShouldReturnOptionFloatSome()
        {
            // Arrange
            var            s        = "1.1";
            Option <float> expected = Some(1.1F);

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

            // Assert
            result.Should().Be(expected);
        }
示例#4
0
        public void ParseWithNumberStylesAndFormatProviderShouldReturnOptionFloatNone()
        {
            // Arrange
            var             s = "p1$234";
            IFormatProvider formatProvider = new NumberFormatInfo()
            {
                PositiveSign = "p"
            };
            Option <float> expected = None;

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

            // Assert
            result.Should().Be(expected);
        }
示例#5
0
        public void ParseWithFormatProviderShouldReturnOptionFloatSome()
        {
            // Arrange
            var             s = "p1234";
            IFormatProvider formatProvider = new NumberFormatInfo()
            {
                PositiveSign = "p"
            };

            Option <float> expected = Some(1234F);

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

            // Assert
            result.Should().Be(expected);
        }