public void WriteJsonShouldThrowExceptionOnNotTimeseriesResult() { TimeseriesResultConverter target = new TimeseriesResultConverter(); // TODO: Initialize to an appropriate value target.WriteJson(null, new object(), null); }
public void WriteJsonShouldConvert() { TimeseriesResultConverter target = new TimeseriesResultConverter(); // TODO: Initialize to an appropriate value using (var ms = new MemoryStream()) { var tw = new StreamWriter(ms); JsonWriter writer = new JsonTextWriter(tw); // TODO: Initialize to an appropriate value JsonSerializer serializer = new JsonSerializer(); // TODO: Initialize to an appropriate value target.WriteJson(writer, m_Result, serializer); writer.Flush(); ms.Position = 0; var result = new StreamReader(ms).ReadToEnd(); Assert.AreEqual("{\"RollupType\":\"Weekly\",\"Timeseries\":[[[\"2009-04-23\",1],[\"2009-04-24\",6],[\"2009-04-25\",3]],[[\"2009-04-23\",4],[\"2009-04-24\",5]]],\"Labels\":[{\"label\":\"Label1\"},{\"label\":\"Label2\"}],\"TimeseriesInfo\":[[{\"Count\":1,\"QuestionCount\":1,\"AnswerCount\":0,\"CommentCount\":0},{\"Count\":6,\"QuestionCount\":6,\"AnswerCount\":0,\"CommentCount\":0},{\"Count\":3,\"QuestionCount\":3,\"AnswerCount\":0,\"CommentCount\":0}],[{\"Count\":4,\"QuestionCount\":4,\"AnswerCount\":0,\"CommentCount\":0},{\"Count\":5,\"QuestionCount\":5,\"AnswerCount\":0,\"CommentCount\":0}]]}", result); } }