public void OperationTelemetryStopAssignsCurrentTimeAsStartTimeAndTimeStampWithoutStart()
 {
     var telemetry = new DependencyTelemetry();
     telemetry.Stop();
     Assert.NotEqual(DateTimeOffset.MinValue, telemetry.StartTime);
     Assert.Equal(telemetry.StartTime, telemetry.Timestamp);
     Assert.Equal(telemetry.Duration, TimeSpan.Zero);
 }
 public void OperationTelemetryStopDoesNotAffectTimeStampAndStartTimeAfterStart()
 {
     var telemetry = new DependencyTelemetry();
     telemetry.Start();
     DateTimeOffset actualTime = telemetry.Timestamp;
     telemetry.Stop();
     Assert.Equal(actualTime, telemetry.Timestamp);
     Assert.Equal(actualTime, telemetry.StartTime);
 }
 public void OperationTelemetryStopComputesDurationAfterStart()
 {
     var telemetry = new DependencyTelemetry();
     telemetry.Start();
     Thread.Sleep(2000);
     Assert.Equal(TimeSpan.Zero, telemetry.Duration);
     telemetry.Stop();
     Assert.True(telemetry.Duration.TotalMilliseconds > 0);
 }
 /// <summary>
 /// Function that needs to be invoked after the request call to the sever. Computes the duration of the request and tracks the dependency telemetry
 /// item.
 /// </summary>
 /// <param name="telemetryClient">Telemetry client object to track the telemetry item.</param>
 /// <param name="telemetry">Telemetry item to compute the duration and track.</param>
 internal static void EndTracking(TelemetryClient telemetryClient, DependencyTelemetry telemetry)
 {
     telemetry.Stop();
     telemetryClient.Track(telemetry);
 }