Ejemplo n.º 1
0
        public void IsInstanceOfType_Null_Throws()
        {
            // arrange
            var type = new FloatType();

            // act
            // assert
            Assert.Throws <ArgumentNullException>(
                () => type.IsInstanceOfType(null));
        }
Ejemplo n.º 2
0
        public void ParseLiteral_Null_Throws()
        {
            // arrange
            var type = new FloatType();

            // act
            // assert
            Assert.Throws <ArgumentNullException>(
                () => type.ParseLiteral(null));
        }
Ejemplo n.º 3
0
        public void Serialize_Null()
        {
            // arrange
            var type = new FloatType();

            // act
            var serializedValue = type.Serialize(null);

            // assert
            Assert.Null(serializedValue);
        }
Ejemplo n.º 4
0
        public void IsInstanceOfType_NullLiteral_True()
        {
            // arrange
            var type = new FloatType();

            // act
            var result = type.IsInstanceOfType(NullValueNode.Default);

            // assert
            Assert.True(result);
        }
Ejemplo n.º 5
0
        public void EnsureFloatTypeKindIsCorret()
        {
            // arrange
            FloatType type = new FloatType();

            // act
            TypeKind kind = type.Kind;

            // assert
            Assert.Equal(TypeKind.Scalar, type.Kind);
        }
Ejemplo n.º 6
0
        public void ParseValue_Wrong_Value_Throws()
        {
            // arrange
            var type  = new FloatType();
            var value = "123";

            // act
            // assert
            Assert.Throws <ScalarSerializationException>(
                () => type.ParseValue(value));
        }
Ejemplo n.º 7
0
        public void IsInstanceOfType_FloatLiteral_True()
        {
            // arrange
            var type = new FloatType();

            // act
            var result = type.IsInstanceOfType(CreateExponentialLiteral());

            // assert
            Assert.True(result);
        }
Ejemplo n.º 8
0
        public void ParseLiteral_Wrong_ValueNode_Throws()
        {
            // arrange
            var type  = new FloatType();
            var input = new StringValueNode("abc");

            // act
            // assert
            Assert.Throws <ScalarSerializationException>(
                () => type.ParseLiteral(input));
        }
Ejemplo n.º 9
0
        public void Ensure_TypeKind_is_Scalar()
        {
            // arrange
            var type = new FloatType();

            // act
            TypeKind kind = type.Kind;

            // assert
            Assert.Equal(TypeKind.Scalar, kind);
        }
Ejemplo n.º 10
0
        public void IsInstanceOfType_IntLiteral_True()
        {
            // arrange
            var type = new FloatType();

            // act
            var result = type.IsInstanceOfType(new IntValueNode(123));

            // assert
            Assert.True(result);
        }
Ejemplo n.º 11
0
        public void ParseLiteral_NullValueNode()
        {
            // arrange
            var type = new FloatType();

            // act
            var output = type.ParseLiteral(NullValueNode.Default);

            // assert
            Assert.Null(output);
        }
Ejemplo n.º 12
0
        public void IsInstanceOfType_StringLiteral_False()
        {
            // arrange
            var type = new FloatType();

            // act
            var result = type.IsInstanceOfType(new StringValueNode("123"));

            // assert
            Assert.False(result);
        }
Ejemplo n.º 13
0
        public void Serialize_MaxValue_Violation()
        {
            // arrange
            var    type  = new FloatType(0, 100);
            double value = 123.456;

            // act
            // assert
            Assert.Throws <ScalarSerializationException>(
                () => type.Serialize(value));
        }
Ejemplo n.º 14
0
        public void Serialize_Wrong_Type_Throws()
        {
            // arrange
            var type  = new FloatType();
            var input = "abc";

            // act
            // assert
            Assert.Throws <ScalarSerializationException>(
                () => type.Serialize(input));
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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());
        }
Ejemplo n.º 17
0
        public void ParseLiteral_NullValueNode()
        {
            // arrange
            FloatType     type  = new FloatType();
            NullValueNode input = new NullValueNode();

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

            // assert
            Assert.Null(output);
        }
Ejemplo n.º 18
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());
        }
Ejemplo n.º 19
0
        public void ParseValue_Null()
        {
            // arrange
            var    type  = new FloatType();
            object input = null;

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

            // assert
            Assert.IsType <NullValueNode>(output);
        }
Ejemplo n.º 20
0
        public void Serialize_Type()
        {
            // arrange
            var    type  = new FloatType();
            double value = 123.456;

            // act
            var serializedValue = type.Serialize(value);

            // assert
            Assert.IsType <double>(serializedValue);
            Assert.Equal(value, serializedValue);
        }
Ejemplo n.º 21
0
        public void ParseLiteral_FloatValueNode()
        {
            // arrange
            FloatType      type  = new FloatType();
            FloatValueNode input = new FloatValueNode("1.000000e+000");

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

            // assert
            Assert.IsType <double>(output);
            Assert.Equal(1.0d, output);
        }
Ejemplo n.º 22
0
        public void ParseLiteral_ExponentialLiteral()
        {
            // arrange
            var            type    = new FloatType();
            FloatValueNode literal = CreateExponentialLiteral();

            // act
            var value = type.ParseLiteral(literal);

            // assert
            Assert.IsType <double>(value);
            Assert.Equal(literal.ToDouble(), value);
        }
Ejemplo n.º 23
0
        public void ParseLiteral_IntLiteral()
        {
            // arrange
            var type    = new FloatType();
            var literal = new IntValueNode(123);

            // act
            var value = type.ParseLiteral(literal);

            // assert
            Assert.IsType <double>(value);
            Assert.Equal(literal.ToDouble(), value);
        }
Ejemplo n.º 24
0
        public void Serialize_Double()
        {
            // arrange
            FloatType type  = new FloatType();
            double    input = 1.0d;

            // act
            object serializedValue = type.Serialize(input);

            // assert
            Assert.IsType <double>(serializedValue);
            Assert.Equal(1.0d, serializedValue);
        }
Ejemplo n.º 25
0
        public void Serialize_Float()
        {
            // arrange
            FloatType type  = new FloatType();
            float     input = 1.0f;

            // act
            object serializedValue = type.Serialize(input);

            // assert
            Assert.IsType <float>(serializedValue);
            Assert.Equal(1.0f, serializedValue);
        }
Ejemplo n.º 26
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);
        }