コード例 #1
0
        public void ShouldSerializeDateTimeOffsetInCorrectStringFormat()
        {
            //Arrange
            var serializer = new CustomJsonSerializer { JsonConverters = GraphClient.DefaultJsonConverters };
            var model = new DateOffsetModel
                {
                    DateTime = DateTimeOffset.Parse("2012-08-31T00:11:00.3642578+10:00"),
                    DateTimeNullable = DateTimeOffset.Parse("2012-08-31T00:11:00.3642578+10:00")
                };

            //Act
            var actual = serializer.Serialize(model);

            //Assert
            const string expected =
                "{\r\n  \"DateTime\": \"2012-08-31T00:11:00.3642578+10:00\",\r\n  \"DateTimeNullable\": \"2012-08-31T00:11:00.3642578+10:00\"\r\n}";
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void ShouldSerializeDateTimeOffsetInCorrectStringFormat()
        {
            //Arrange
            var serializer = new CustomJsonSerializer {
                JsonConverters = GraphClient.DefaultJsonConverters
            };
            var model = new DateOffsetModel
            {
                DateTime         = DateTimeOffset.Parse("2012-08-31T00:11:00.3642578+10:00"),
                DateTimeNullable = DateTimeOffset.Parse("2012-08-31T00:11:00.3642578+10:00")
            };

            //Act
            var actual = serializer.Serialize(model);

            //Assert
            const string expected =
                "{\r\n  \"DateTime\": \"2012-08-31T00:11:00.3642578+10:00\",\r\n  \"DateTimeNullable\": \"2012-08-31T00:11:00.3642578+10:00\"\r\n}";

            Assert.Equal(expected, actual);
        }