Exemplo n.º 1
0
        public void Serialize_String_Exception()
        {
            // arrange
            DateType dateType = new DateType();

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

            // assert
            Assert.Throws <ArgumentException>(a);
        }
Exemplo n.º 2
0
        public void Serialize_Null()
        {
            // arrange
            DateType dateType = new DateType();

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

            // assert
            Assert.Null(serializedValue);
        }
Exemplo n.º 3
0
        public void Serialize_String_Exception()
        {
            // arrange
            var dateType = new DateType();

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

            // assert
            Assert.Throws <ScalarSerializationException>(a);
        }
Exemplo n.º 4
0
        public void Serialize_Date()
        {
            // arrange
            DateType dateType = new DateType();
            DateTime dateTime = new DateTime(
                2018, 6, 11, 8, 46, 14, DateTimeKind.Utc);
            string expectedValue = "2018-06-11";

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

            // assert
            Assert.Equal(expectedValue, serializedValue);
        }
Exemplo n.º 5
0
        public void Serialize_DateTimeOffset()
        {
            // arrange
            DateType       dateType = new DateType();
            DateTimeOffset dateTime = new DateTimeOffset(
                new DateTime(2018, 6, 11, 8, 46, 14),
                new TimeSpan(4, 0, 0));
            string expectedValue = "2018-06-11";

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

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