public void Deserialize_Report() { TelemetryReport tempReport = new TelemetryReport(); tempReport.LogDataPoint("int", 5); tempReport.LogDataPoint("string", "foo"); tempReport.LogDataPoint("double", 3.14); tempReport.LogDataPoint("bool", true); tempReport.SetLogTime(DateTime.UtcNow); tempReport.ErrorCode = 7; tempReport.StatusCode = 5; JsonSerializer serializer = new JsonSerializer(); string result = serializer.SerializeToText(tempReport); TelemetryReport report = serializer.DeserializeReports(result)[0]; Assert.AreEqual(DateTime.UtcNow.Year, report.ActivityTime.Year); Assert.AreEqual(5, report.StatusCode); Assert.AreEqual(7, report.ErrorCode); Assert.AreEqual((long)5, report.GetDataPointValue("int")); Assert.AreEqual("foo", report.GetDataPointValue("string")); Assert.AreEqual(3.14, report.GetDataPointValue("double")); Assert.AreEqual(true, report.GetDataPointValue("bool")); }
public void Serialize_Report() { TelemetryReport report = new TelemetryReport(); report.LogDataPoint("int", 5); report.LogDataPoint("string", "foo"); report.LogDataPoint("double", 3.14); report.LogDataPoint("bool", true); JsonSerializer serializer = new JsonSerializer(); string result = serializer.SerializeToText(report); Debug.WriteLine(result); }