Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate DateTime.Now to DateTime.UtcNow to make sure all test reporti… #1612

Merged
merged 5 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ internal string WriteEventLogs(List<EventLogEntry> eventLogEntries, int maxLogEn
"{0}-{1}-{2:yyyy}{2:MM}{2:dd}-{2:HH}{2:mm}{2:ss}.{2:fff}",
"Event Log",
Environment.MachineName,
DateTime.Now);
DateTime.UtcNow);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


string eventLogDirPath = Path.Combine(Path.GetTempPath(), eventLogDirName);

Expand Down Expand Up @@ -413,7 +413,7 @@ private void OnSessionEnd(object sender, SessionEndEventArgs e)
EqtTrace.Verbose("EventLogDataCollector: SessionEnd received");
}

this.WriteCollectedEventLogEntries(e.Context, true, TimeSpan.MaxValue, DateTime.Now);
this.WriteCollectedEventLogEntries(e.Context, true, TimeSpan.MaxValue, DateTime.UtcNow);
}

private void OnTestCaseStart(object sender, TestCaseStartEventArgs e)
Expand Down Expand Up @@ -450,7 +450,7 @@ private void OnTestCaseEnd(object sender, TestCaseEndEventArgs e)
e.TestOutcome);
}

this.WriteCollectedEventLogEntries(e.Context, false, TimeSpan.MaxValue, DateTime.Now);
this.WriteCollectedEventLogEntries(e.Context, false, TimeSpan.MaxValue, DateTime.UtcNow);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public RunInfo(string textMessage, Exception ex, string computer, TestOutcome ou
this.exception = ex;
this.computer = computer;
this.outcome = outcome;
this.timestamp = DateTime.Now.ToUniversalTime();
this.timestamp = DateTime.UtcNow;
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ private void Initialize()
{
this.runUser = string.Empty;
}
this.created = DateTime.Now.ToUniversalTime();
this.queued = DateTime.Now.ToUniversalTime();
this.started = DateTime.Now.ToUniversalTime();
this.finished = DateTime.Now.ToUniversalTime();
this.created = DateTime.UtcNow;
this.queued = DateTime.UtcNow;
this.started = DateTime.UtcNow;
this.finished = DateTime.UtcNow;
}
}
}
8 changes: 4 additions & 4 deletions src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e)
XmlElement rootElement = helper.CreateRootElement("TestRun");

// Save runId/username/creation time etc.
this.testRun.Finished = DateTime.Now;
this.testRun.Finished = DateTime.UtcNow;
helper.SaveSingleFields(rootElement, this.testRun, parameters);

// Save test settings
Expand Down Expand Up @@ -410,7 +410,7 @@ private void InitializeInternal()
this.passTests = 0;
this.failTests = 0;
this.runLevelStdOut = new StringBuilder();
this.testRunStartTime = DateTime.Now;
this.testRunStartTime = DateTime.UtcNow;
}

/// <summary>
Expand Down Expand Up @@ -589,7 +589,7 @@ private void UpdateTestLinks(ITestElement testElement, ITestElement parentTestEl
/// <param name="parentTestResult"></param>
/// <param name="rocksteadyTestResult"></param>
/// <returns>Trx test result</returns>
private ITestResult CreateTestResult(Guid executionId, Guid parentExecutionId, TestType testType,
private ITestResult CreateTestResult(Guid executionId, Guid parentExecutionId, TestType testType,
ITestElement testElement, ITestElement parentTestElement, ITestResult parentTestResult, ObjectModel.TestResult rocksteadyTestResult)
{
// Create test result
Expand All @@ -611,7 +611,7 @@ private ITestResult CreateTestResult(Guid executionId, Guid parentExecutionId, T
this.innerResults.TryAdd(executionId, testResult);
return testResult;
}

// Data driven inner result scenario
if (parentTestElement != null && parentTestElement.TestType.Equals(TrxLoggerConstants.UnitTestType))
{
Expand Down