public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.ValueType == typeof(DateTime)) { return(ScheduleTiming.Create(((DateTime)reader.Value).ToString("s"))); } return(ScheduleTiming.Create(reader.Value.ToString())); }
public void CreateScheduleTimingTest(string serializedTimer, DateTime expectedDateTime, TimeSpan expectedRandomOffset, int expectedLoops, int expectedType, int expectedWeekdays) { var result = ScheduleTiming.Create(serializedTimer); Assert.Equal(result.BaseDate, expectedDateTime); Assert.Equal(result.RandomizedOffSet, expectedRandomOffset); Assert.Equal(result.Loops, expectedLoops); Assert.Equal((int)result.Type, expectedType); Assert.Equal((int)result.Weekdays, expectedWeekdays); Assert.Equal(serializedTimer, result.ToJson()); }