示例#1
0
        public void Write()
        {
            // Arrange
            var sb     = new StringBuilder();
            var sw     = new StringWriter(sb);
            var writer = new JsonTextWriter(sw);

            var value      = new DateTime(2017, 3, 28, 16, 19, 0, DateTimeKind.Utc);
            var serializer = new JsonSerializer();

            var converter = new SendGridDateTimeConverter();

            // Act
            converter.WriteJson(writer, value, serializer);
            var result = sb.ToString();

            // Assert
            result.ShouldBe("\"2017-03-28 16:19:00\"");
        }
示例#2
0
        public void Write_null()
        {
            // Arrange
            var sb     = new StringBuilder();
            var sw     = new StringWriter(sb);
            var writer = new JsonTextWriter(sw);

            var value      = (object)null;
            var serializer = new JsonSerializer();

            var converter = new SendGridDateTimeConverter();

            // Act
            converter.WriteJson(writer, value, serializer);
            var result = sb.ToString();

            // Assert
            result.ShouldBeEmpty();
        }