Esempio n. 1
0
        public void Serialize_String_Exception()
        {
            // arrange
            var dateTimeType = new DateTimeType();

            // act
            Action a = () => dateTimeType.Serialize("foo");

            // assert
            Assert.Throws <ScalarSerializationException>(a);
        }
Esempio n. 2
0
        public void Serialize_Null()
        {
            // arrange
            var dateTimeType = new DateTimeType();

            // act
            object serializedValue = dateTimeType.Serialize(null);

            // assert
            Assert.Null(serializedValue);
        }
        public void Serialize_String_Exception()
        {
            // arrange
            DateTimeType dateTimeType = new DateTimeType();

            // act
            Action a = () => dateTimeType.Serialize("foo");

            // assert
            Assert.Throws <ArgumentException>(a);
        }
        public void Serialize_Utc_DateTime()
        {
            // arrange
            DateTimeType dateTimeType = new DateTimeType();
            DateTime     dateTime     = new DateTime(
                2018, 6, 11, 8, 46, 14, DateTimeKind.Utc);
            string expectedValue = "2018-06-11T08:46:14.000Z";

            // act
            string serializedValue = (string)dateTimeType.Serialize(dateTime);

            // assert
            Assert.Equal(expectedValue, serializedValue);
        }
Esempio n. 5
0
        public void Serialize_DateTimeOffset()
        {
            // arrange
            var dateTimeType = new DateTimeType();
            var dateTime     = new DateTimeOffset(
                new DateTime(2018, 6, 11, 8, 46, 14),
                new TimeSpan(4, 0, 0));
            string expectedValue = "2018-06-11T08:46:14.000+04:00";

            // act
            string serializedValue = (string)dateTimeType.Serialize(dateTime);

            // assert
            Assert.Equal(expectedValue, serializedValue);
        }