public void Serialize_Null()
        {
            // arrange
            var type = new DecimalType();

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

            // assert
            Assert.Null(serializedValue);
        }
        public void Serialize_Wrong_Type_Throws()
        {
            // arrange
            var type  = new DecimalType();
            var input = "abc";

            // act
            // assert
            Assert.Throws <SerializationException>(
                () => type.Serialize(input));
        }
        public void Serialize_MaxValue_Violation()
        {
            // arrange
            var     type  = new DecimalType(0, 100);
            decimal value = 123.456M;

            // act
            // assert
            Assert.Throws <SerializationException>(
                () => type.Serialize(value));
        }
        public void Serialize_Type()
        {
            // arrange
            var     type  = new DecimalType();
            decimal value = 123.456M;

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

            // assert
            Assert.IsType <decimal>(serializedValue);
            Assert.Equal(value, serializedValue);
        }
Beispiel #5
0
        public void Serialize_Decimal()
        {
            // arrange
            DecimalType type  = new DecimalType();
            decimal     input = 1.0m;

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

            // assert
            Assert.IsType <decimal>(serializedValue);
            Assert.Equal(1.0m, serializedValue);
        }