public void OperationTelemetryStartInitializesTimeStampAndStartTimeToTelemetry()
 {
     var telemetry = new DependencyTelemetry();
     Assert.Equal(telemetry.StartTime, DateTimeOffset.MinValue);
     Assert.Equal(telemetry.Timestamp, DateTimeOffset.MinValue);
     telemetry.Start();
     Assert.Equal(telemetry.StartTime, telemetry.Timestamp);
 }
 /// <summary>
 /// The function that needs to be called before sending a request to the server. Creates and initializes dependency telemetry item.
 /// </summary>
 /// <param name="telemetryClient">Telemetry client object to initialize the context of the telemetry item.</param>
 internal static DependencyTelemetry BeginTracking(TelemetryClient telemetryClient)
 {
     var telemetry = new DependencyTelemetry();
     telemetry.Start();
     telemetryClient.Initialize(telemetry);
     PretendProfilerIsAttached = false;
     return telemetry;
 }
 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);
 }
 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);
 }