public void Read_null() { // Arrange var json = ""; var textReader = new StringReader(json); var jsonReader = new JsonTextReader(textReader); var objectType = (Type)null; var existingValue = (object)null; var serializer = new JsonSerializer(); var converter = new SendGridDateTimeConverter(); // Act jsonReader.Read(); var result = converter.ReadJson(jsonReader, objectType, existingValue, serializer); // Assert result.ShouldBeNull(); }
public void Read() { // Arrange var json = "\"2017-03-28 16:19:00\""; var textReader = new StringReader(json); var jsonReader = new JsonTextReader(textReader); var objectType = (Type)null; var existingValue = (object)null; var serializer = new JsonSerializer(); var converter = new SendGridDateTimeConverter(); // Act jsonReader.Read(); var result = converter.ReadJson(jsonReader, objectType, existingValue, serializer); // Assert result.ShouldNotBeNull(); result.ShouldBeOfType <DateTime>(); ((DateTime)result).ShouldBe(new DateTime(2017, 3, 28, 16, 19, 0, DateTimeKind.Utc)); }