Converts Epoch (Unix) timestamps to DateTimeOffsets.
Inheritance: Newtonsoft.Json.JsonConverter
        public void ReadJson(DateTimeOffset expected, string original)
        {
            var converter = new EpochTimeConverter();

            var reader = new JsonTextReader(new StringReader(original));
            reader.Read();
            var serializer = new JsonSerializer();

            var actual = (DateTimeOffset) converter.ReadJson(reader, typeof(DateTimeOffset), null, serializer);

            Assert.Equal(expected, actual);
        }
        public void ReadJson_ThrowsInvalidCastException(string data)
        {
            var converter = new EpochTimeConverter();

            var reader = new JsonTextReader(new StringReader(data));
            reader.Read();
            var serializer = new JsonSerializer();

            var exception = Record.Exception(() => converter.ReadJson(reader, typeof(DateTimeOffset), null, serializer));
            Assert.NotNull(exception);
            Assert.IsType<InvalidCastException>(exception);
        }
        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 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 CanConvert(Type type, bool canConvert)
        {
            var converter = new EpochTimeConverter();

            Assert.Equal(converter.CanConvert(type), canConvert);
        }