internal static void ValidateCosmosDiagnosticsContext( CosmosDiagnosticsContext cosmosDiagnosticsContext) { Assert.IsTrue((cosmosDiagnosticsContext.StartUtc - DateTime.UtcNow) < TimeSpan.FromHours(12), $"Start Time is not valid {cosmosDiagnosticsContext.StartUtc}"); Assert.AreNotEqual(cosmosDiagnosticsContext.UserAgent.ToString(), new UserAgentContainer().UserAgent.ToString(), "User agent not set"); Assert.IsTrue(cosmosDiagnosticsContext.TotalRequestCount > 0, "No request found"); Assert.IsFalse(cosmosDiagnosticsContext.IsComplete(), "OverallClientRequestTime should be stopped"); Assert.IsTrue(cosmosDiagnosticsContext.GetClientElapsedTime() > TimeSpan.Zero, "OverallClientRequestTime should have time."); string info = cosmosDiagnosticsContext.ToString(); Assert.IsNotNull(info); JObject jObject = JObject.Parse(info.ToString()); JToken summary = jObject["Summary"]; Assert.IsNotNull(summary["UserAgent"].ToString()); Assert.AreNotEqual(summary["UserAgent"].ToString(), new UserAgentContainer().UserAgent); Assert.IsNotNull(summary["StartUtc"].ToString()); Assert.IsNotNull(summary["TotalElapsedTime"].ToString()); }
internal static void ValidateCosmosDiagnosticsContext( CosmosDiagnosticsContext cosmosDiagnosticsContext) { Assert.IsTrue((cosmosDiagnosticsContext.StartUtc - DateTime.UtcNow) < TimeSpan.FromHours(12), $"Start Time is not valid {cosmosDiagnosticsContext.StartUtc}"); Assert.IsTrue(cosmosDiagnosticsContext.UserAgent.ToString().Contains("cosmos-netstandard-sdk")); Assert.IsTrue(cosmosDiagnosticsContext.GetTotalRequestCount() > 0, "No request found"); Assert.IsTrue(cosmosDiagnosticsContext.IsComplete(), "OverallClientRequestTime should be stopped"); Assert.IsTrue(cosmosDiagnosticsContext.GetRunningElapsedTime() > TimeSpan.Zero, "OverallClientRequestTime should have time."); string info = cosmosDiagnosticsContext.ToString(); Assert.IsNotNull(info); JObject jObject = JObject.Parse(info.ToString()); Assert.IsNotNull(jObject["DiagnosticVersion"].ToString()); JToken summary = jObject["Summary"]; Assert.IsNotNull(summary["UserAgent"].ToString()); Assert.IsTrue(summary["UserAgent"].ToString().Contains("cosmos-netstandard-sdk")); Assert.IsNotNull(summary["StartUtc"].ToString()); Assert.IsNotNull(summary["TotalElapsedTimeInMs"].ToString()); }