예제 #1
0
        public void Serialize_Null()
        {
            // arrange
            var type = new FloatType();

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

            // assert
            Assert.Null(serializedValue);
        }
예제 #2
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));
        }
예제 #3
0
        public void Serialize_Wrong_Type_Throws()
        {
            // arrange
            var type  = new FloatType();
            var input = "abc";

            // act
            // assert
            Assert.Throws <ScalarSerializationException>(
                () => type.Serialize(input));
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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);
        }