public void WriteJson_ThrowsInvalidCastException(object data) { var converter = new EpochTimeConverter(); var sb = new StringBuilder(); var stringWriter = new StringWriter(sb); var writer = new JsonTextWriter(stringWriter); var serializer = new JsonSerializer(); var exception = Record.Exception(() => converter.WriteJson(writer, data, serializer)); Assert.NotNull(exception); Assert.IsType <InvalidCastException>(exception); }
public void EpochTimeConverter_WriteJsonString_ThrowsInvalidCastException() { var converter = new EpochTimeConverter(); var sb = new StringBuilder(); var stringWriter = new StringWriter(sb); var writer = new JsonTextWriter(stringWriter); var serializer = new JsonSerializer(); converter.WriteJson(writer, "xyz", serializer); var actual = sb.ToString(); Assert.AreNotEqual("1439134235", actual); }
public void WriteJson(string expected, DateTimeOffset original) { var converter = new EpochTimeConverter(); var sb = new StringBuilder(); var stringWriter = new StringWriter(sb); var writer = new JsonTextWriter(stringWriter); var serializer = new JsonSerializer(); converter.WriteJson(writer, original, serializer); var actual = sb.ToString(); Assert.Equal(expected, actual); }
public void EpochTimeConverter_WriteJsonInt64_AreNotEqual() { var converter = new EpochTimeConverter(); var sb = new StringBuilder(); var stringWriter = new StringWriter(sb); var writer = new JsonTextWriter(stringWriter); var serializer = new JsonSerializer(); var date = new DateTimeOffset(new DateTime(2015, 8, 4, 15, 30, 32, DateTimeKind.Utc)); converter.WriteJson(writer, date, serializer); var actual = sb.ToString(); Assert.AreNotEqual("1439134235", actual); }