Example #1
0
        public void ParseValue_Wrong_Value_Throws()
        {
            // arrange
            var type  = new FloatType();
            var value = "123";

            // act
            // assert
            Assert.Throws <ScalarSerializationException>(
                () => type.ParseValue(value));
        }
Example #2
0
        public void ParseValue_Nullable()
        {
            // arrange
            var    type  = new FloatType();
            double?input = 123;

            // act
            FloatValueNode output = (FloatValueNode)type.ParseValue(input);

            // assert
            Assert.Equal(123, output.ToDouble());
        }
Example #3
0
        public void ParseValue_Null()
        {
            // arrange
            var    type  = new FloatType();
            object input = null;

            // act
            object output = type.ParseValue(input);

            // assert
            Assert.IsType <NullValueNode>(output);
        }
Example #4
0
        public void ParseValue_MinValue_Violation()
        {
            // arrange
            var    type  = new FloatType(1, 100);
            double input = 0;

            // act
            Action action = () => type.ParseValue(input);

            // assert
            Assert.Throws <ScalarSerializationException>(action);
        }
Example #5
0
        public void ParseValue_MinValue()
        {
            // arrange
            var    type  = new FloatType(1, 100);
            double input = 1;

            // act
            var literal = (FloatValueNode)type.ParseValue(input);

            // assert
            Assert.Equal(1, literal.ToDouble());
        }
Example #6
0
        public void ParseValue_Double()
        {
            // arrange
            FloatType type  = new FloatType();
            double    input = 1.0d;
            string    expectedLiteralValue = "1.000000e+000";

            // act
            FloatValueNode literal =
                (FloatValueNode)type.ParseValue(input);

            // assert
            Assert.Equal(expectedLiteralValue, literal.Value);
        }