Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smadala committed Jan 5, 2018
1 parent 56a25cf commit 1980aa0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void InitializeShouldSaveExceptionMessagesIfThrownByDataCollectionProcess
{
var mockRequestSender = new Mock<IDataCollectionRequestSender>();
mockRequestSender.Setup(x => x.SendBeforeTestRunStartAndGetResult(It.IsAny<string>(), It.IsAny<ITestMessageEventHandler>())).Throws(new Exception("MyException"));
mockRequestSender.Setup(x => x.WaitForRequestHandlerConnection(ProxyDataCollectionManager.DataCollectorConnectionTimeout)).Returns(true);

var mockDataCollectionLauncher = new Mock<IDataCollectionLauncher>();
var proxyDataCollectonManager = new ProxyDataCollectionManager(this.mockRequestData.Object, string.Empty, mockRequestSender.Object, this.mockProcessHelper.Object, mockDataCollectionLauncher.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void Initialize()
[TestMethod]
public void InitializeShouldInitializeCommunication()
{
this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(ProxyDataCollectionManager.DataCollectorConnectionTimeout)).Returns(true);
this.proxyDataCollectionManager.Initialize();

this.mockDataCollectionLauncher.Verify(x => x.LaunchDataCollector(It.IsAny<IDictionary<string, string>>(), It.IsAny<IList<string>>()), Times.Once);
Expand All @@ -65,8 +66,10 @@ public void InitializeShouldThrowExceptionIfConnectionTimeouts()
[TestMethod]
public void InitializeShouldSetTimeoutBasedOnTimeoutEnvironmentVarible()
{

var timeout = 10;
Environment.SetEnvironmentVariable(ProxyDataCollectionManager.TimeoutEnvironmentVaribleName, timeout.ToString());
this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(timeout * 1000)).Returns(true);

this.proxyDataCollectionManager.Initialize();
Environment.SetEnvironmentVariable(ProxyDataCollectionManager.TimeoutEnvironmentVaribleName, string.Empty);
Expand All @@ -78,6 +81,7 @@ public void InitializeShouldSetTimeoutBasedOnTimeoutEnvironmentVarible()
public void InitializeShouldSetTimeoutBasedOnDebugEnvironmentVaribleName()
{
Environment.SetEnvironmentVariable(ProxyDataCollectionManager.DebugEnvironmentVaribleName, "1");
this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(ProxyDataCollectionManager.DataCollectorConnectionTimeout * 5)).Returns(true);

this.proxyDataCollectionManager.Initialize();
Environment.SetEnvironmentVariable(ProxyDataCollectionManager.DebugEnvironmentVaribleName, string.Empty);
Expand All @@ -101,6 +105,7 @@ public void InitializeShouldPassDiagArgumentsIfDiagIsEnabled()
try
{
EqtTrace.InitializeVerboseTrace("mylog.txt");
this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(ProxyDataCollectionManager.DataCollectorConnectionTimeout)).Returns(true);

this.proxyDataCollectionManager.Initialize();

Expand Down

0 comments on commit 1980aa0

Please sign in to comment.