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

switch arguments for expected and actual in Assert.AreEquals in multiple tests #2329

Merged
merged 13 commits into from
Feb 24, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ParallelRunEventsHandler(IRequestData requestData,
IProxyExecutionManager proxyExecutionManager,
ITestRunEventsHandler actualRunEventsHandler,
IParallelProxyExecutionManager parallelProxyExecutionManager,
ParallelRunDataAggregator runDataAggregator) :
ParallelRunDataAggregator runDataAggregator) :
this(requestData, proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, JsonDataSerializer.Instance)
{
}
Expand Down Expand Up @@ -95,15 +95,15 @@ protected bool HandleSingleTestRunComplete(TestRunCompleteEventArgs testRunCompl
{
// we get run complete events from each executor process
// so we cannot "complete" the actual executor operation until all sources/testcases are consumed
// We should not block last chunk results while we aggregate overall run data
// We should not block last chunk results while we aggregate overall run data
if (lastChunkArgs != null)
{
ConvertToRawMessageAndSend(MessageType.TestRunStatsChange, lastChunkArgs);
HandleTestRunStatsChange(lastChunkArgs);
}

// Update runstats, executorUris, etc.
// we need this data when we send the final runcomplete
// Update runstats, executorUris, etc.
// we need this data when we send the final runcomplete
this.runDataAggregator.Aggregate(
testRunCompleteArgs.TestRunStatistics,
executorUris,
Expand All @@ -128,7 +128,7 @@ protected bool HandleSingleTestRunComplete(TestRunCompleteEventArgs testRunCompl
protected void HandleParallelTestRunComplete(TestRunCompleteEventArgs completedArgs)
{
// In case of sequential execution - RawMessage would have contained a 'TestRunCompletePayload' object
// To send a rawmessge - we need to create rawmessage from an aggregated payload object
// To send a rawmessge - we need to create rawmessage from an aggregated payload object
var testRunCompletePayload = new TestRunCompletePayload()
{
ExecutorUris = this.runDataAggregator.ExecutorUris,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public void ConstructorShouldNotInitializeNameValuePairIfEmptyXmlElementIsPassed
}

var configManager = new CollectorNameValueConfigurationManager(xmlDocument.DocumentElement);
Assert.AreEqual(configManager.NameValuePairs.Count, 0);
Assert.AreEqual(0, configManager.NameValuePairs.Count);
}

[TestMethod]
public void ConstructorShouldNotInitializeNameValuePairNullIsPassed()
{
var configManager = new CollectorNameValueConfigurationManager(null);
Assert.AreEqual(configManager.NameValuePairs.Count, 0);
Assert.AreEqual(0, configManager.NameValuePairs.Count);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,21 @@ public void InitializeShouldSubscribeToDataCollectionEvents()
public void TestSessionStartEventShouldCreateEventLogContainer()
{
var eventLogDataCollector = new EventLogDataCollector();
Assert.AreEqual(eventLogDataCollector.ContextMap.Count, 0);
Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count);
eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext);
this.mockDataCollectionEvents.Raise(x => x.SessionStart += null, new SessionStartEventArgs());
Assert.AreEqual(eventLogDataCollector.ContextMap.Count, 1);
Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count);
}

[TestMethod]
public void TestCaseStartEventShouldCreateEventLogContainer()
{
var eventLogDataCollector = new EventLogDataCollector();
Assert.AreEqual(eventLogDataCollector.ContextMap.Count, 0);
Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count);

eventLogDataCollector.Initialize(null, this.mockDataCollectionEvents.Object, this.mockDataCollectionSink, this.mockDataCollectionLogger.Object, this.dataCollectionEnvironmentContext);
this.mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())), new TestCase()));
Assert.AreEqual(eventLogDataCollector.ContextMap.Count, 1);
Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void InitializeShouldNotThrowOnNullConfig()

this.collector.Initialize(null, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object);

Assert.AreEqual(null, actualConfig);
Assert.IsNull(actualConfig);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void DesignModeTestHostFactoryShouldReturnNonDebugLauncherIfDebuggingDisa
var mockDesignModeClient = new Mock<IDesignModeClient>();
var testRunRequestPayload = new TestRunRequestPayload { DebuggingEnabled = false };
var launcher = DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(mockDesignModeClient.Object, testRunRequestPayload);

Assert.IsFalse(launcher.IsDebug, "Factory must not return debug launcher if debugging is disabled.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public void FastFilterWithWithRegexParseErrorShouldNotCreateFastFilter()
{
var filterExpressionWrapper = new FilterExpressionWrapper("FullyQualifiedName=Test", new FilterOptions() { FilterRegEx = @"^[^\s\(]+\1" });

Assert.AreEqual(null, filterExpressionWrapper.fastFilter);
Assert.IsNull(filterExpressionWrapper.fastFilter);
Assert.IsFalse(string.IsNullOrEmpty(filterExpressionWrapper.ParseError));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void RequestDataShouldReturnIsTelemetryOptedInTrueIfTelemetryOptedIn()
var requestData = new RequestData();
requestData.IsTelemetryOptedIn = true;

Assert.AreEqual(true, requestData.IsTelemetryOptedIn);
Assert.IsTrue(requestData.IsTelemetryOptedIn);
}

[TestMethod]
Expand All @@ -63,7 +63,7 @@ public void RequestDataShouldReturnIsTelemetryOptedInFalseIfTelemetryOptedOut()
var requestData = new RequestData();
requestData.IsTelemetryOptedIn = false;

Assert.AreEqual(false, requestData.IsTelemetryOptedIn);
Assert.IsFalse(requestData.IsTelemetryOptedIn);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public void AddShouldAddMetric()
this.metricsCollection.Add("DummyMessage", "DummyValue");

object value;
Assert.AreEqual(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out value), true);
Assert.AreEqual(value, "DummyValue");
Assert.IsTrue(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out value));
Assert.AreEqual("DummyValue", value);
}

[TestMethod]
Expand All @@ -33,14 +33,14 @@ public void AddShouldUpdateMetricIfSameKeyIsPresentAlready()
this.metricsCollection.Add("DummyMessage", "DummyValue");

object value;
Assert.AreEqual(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out value), true);
Assert.AreEqual(value, "DummyValue");
Assert.IsTrue(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out value));
Assert.AreEqual("DummyValue", value);

this.metricsCollection.Add("DummyMessage", "newValue");

object newValue;
Assert.AreEqual(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out newValue), true);
Assert.AreEqual(newValue, "newValue");
Assert.IsTrue(this.metricsCollection.Metrics.TryGetValue("DummyMessage", out newValue));
Assert.AreEqual("newValue", newValue);
}

[TestMethod]
Expand All @@ -49,15 +49,15 @@ public void MetricsShouldReturnValidMetricsIfValidItemsAreThere()
this.metricsCollection.Add("DummyMessage", "DummyValue");
this.metricsCollection.Add("DummyMessage2", "DummyValue");

Assert.AreEqual(this.metricsCollection.Metrics.Count, 2);
Assert.AreEqual(this.metricsCollection.Metrics.ContainsKey("DummyMessage"), true);
Assert.AreEqual(this.metricsCollection.Metrics.ContainsKey("DummyMessage2"), true);
Assert.AreEqual(2, this.metricsCollection.Metrics.Count);
Assert.IsTrue(this.metricsCollection.Metrics.ContainsKey("DummyMessage"));
Assert.IsTrue(this.metricsCollection.Metrics.ContainsKey("DummyMessage2"));
}

[TestMethod]
public void MetricsShouldReturnEmptyDictionaryIfMetricsIsEmpty()
{
Assert.AreEqual(this.metricsCollection.Metrics.Count, 0);
Assert.AreEqual(0, this.metricsCollection.Metrics.Count);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void CreateRunSettingsShouldReturnValidRunSettings()
TestPluginCacheTests.SetupMockExtensions();
string runsettings = @"<RunSettings><RunConfiguration><ResultsDirectory>.\TestResults</ResultsDirectory></RunConfiguration ><DummyMSTest><FORCEDLEGACYMODE>true</FORCEDLEGACYMODE></DummyMSTest></RunSettings>";
var result= RunSettingsUtilities.CreateAndInitializeRunSettings(runsettings);
Assert.AreEqual(DummyMsTestSetingsProvider.StringToVerify, "<DummyMSTest><FORCEDLEGACYMODE>true</FORCEDLEGACYMODE></DummyMSTest>");
Assert.AreEqual("<DummyMSTest><FORCEDLEGACYMODE>true</FORCEDLEGACYMODE></DummyMSTest>", DummyMsTestSetingsProvider.StringToVerify);
TestPluginCacheTests.ResetExtensionsCache();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public void SendAfterTestRunEndAndGetResultShouldReturnAttachments()
var attachmentSets = this.requestSender.SendAfterTestRunEndAndGetResult(null, false);

Assert.IsNotNull(attachmentSets);
Assert.AreEqual(attachmentSets.Count, 1);
Assert.AreEqual(1, attachmentSets.Count);
Assert.IsNotNull(attachmentSets[0]);
Assert.AreEqual(attachmentSets[0].DisplayName, displayName);
Assert.AreEqual(displayName, attachmentSets[0].DisplayName);
Assert.AreEqual(datacollectorUri, attachmentSets[0].Uri);
Assert.AreEqual(attachmentUri, attachmentSets[0].Attachments[0].Uri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void SerializePayloadShouldNotPickDefaultSettings()
classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop;

string serializedPayload = this.jsonDataSerializer.SerializePayload("dummy", classWithSelfReferencingLoop);
Assert.AreEqual(serializedPayload, "{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}");
Assert.AreEqual("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}", serializedPayload);
}

[TestMethod]
Expand All @@ -55,7 +55,7 @@ public void DeserializeMessageShouldNotPickDefaultSettings()
};

Message message = this.jsonDataSerializer.DeserializeMessage("{\"MessageType\":\"dummy\",\"Payload\":{\"InfiniteRefernce\":{}}}");
Assert.AreEqual(message?.MessageType, "dummy");
Assert.AreEqual("dummy", message?.MessageType);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void InitializeCommunicationShouldHostServerAndAcceptClient()
{
var port = this.SetupFakeCommunicationChannel();

Assert.AreEqual(port, "123", "Correct port must be returned.");
Assert.AreEqual("123", port, "Correct port must be returned.");
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void GetStringArgFromDictShouldReturnNullIfValueIsNotPresent()
string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--hello");

Assert.IsTrue(argsDictionary.Count == 2);
Assert.AreEqual(null, data);
Assert.IsNull(data);
}

[TestMethod]
Expand Down Expand Up @@ -91,8 +91,8 @@ public void GetArgumentsDictionaryShouldTreatValueAsNullIfTwoConsecutiveKeysAreP
var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray());

Assert.IsTrue(argsDictionary.Count == 2);
Assert.AreEqual(null, argsDictionary["--hello"]);
Assert.AreEqual(null, argsDictionary["--world"]);
Assert.IsNull(argsDictionary["--hello"]);
Assert.IsNull(argsDictionary["--world"]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void CheckIfTraceStateIsVerboseEnabled()
#else
EqtTrace.TraceLevel = PlatformTraceLevel.Verbose;
#endif
Assert.AreEqual(true, EqtTrace.IsVerboseEnabled, "Expected trace state to be verbose actual state {0}", EqtTrace.IsVerboseEnabled);
Assert.IsTrue(EqtTrace.IsVerboseEnabled, "Expected trace state to be verbose actual state {0}", EqtTrace.IsVerboseEnabled);
}

[TestMethod]
Expand All @@ -61,7 +61,7 @@ public void CheckIfTraceStateIsErrorEnabled()
#else
EqtTrace.TraceLevel = PlatformTraceLevel.Error;
#endif
Assert.AreEqual(true, EqtTrace.IsErrorEnabled, "Expected trace state to be error actual state {0}", EqtTrace.IsErrorEnabled);
Assert.IsTrue(EqtTrace.IsErrorEnabled, "Expected trace state to be error actual state {0}", EqtTrace.IsErrorEnabled);
}

[TestMethod]
Expand All @@ -72,7 +72,7 @@ public void CheckIfTraceStateIsInfoEnabled()
#else
EqtTrace.TraceLevel = PlatformTraceLevel.Info;
#endif
Assert.AreEqual(true, EqtTrace.IsInfoEnabled, "Expected trace state to be info actual state {0}", EqtTrace.IsInfoEnabled);
Assert.IsTrue(EqtTrace.IsInfoEnabled, "Expected trace state to be info actual state {0}", EqtTrace.IsInfoEnabled);
}

[TestMethod]
Expand All @@ -83,7 +83,7 @@ public void CheckIfTraceStateIsWarningEnabled()
#else
EqtTrace.TraceLevel = PlatformTraceLevel.Warning;
#endif
Assert.AreEqual(true, EqtTrace.IsWarningEnabled, "Expected trace state to be warning actual state {0}", EqtTrace.IsWarningEnabled);
Assert.IsTrue(EqtTrace.IsWarningEnabled, "Expected trace state to be warning actual state {0}", EqtTrace.IsWarningEnabled);
}

[TestMethod]
Expand Down
Loading