public void TriggerTestCaseEndShouldtBeCalledMultipleTimesInDataDrivenScenario() { var inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, null); Assert.IsTrue(inProcDataCollectionManager.IsInProcDataCollectionEnabled, "InProcDataCollection must be enabled if runsettings contains inproc datacollectors."); Assert.AreEqual(inProcDataCollectionManager.DataCollectors.Count, 1, "One Datacollector must be registered"); var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); // random guid testCase.Id = new Guid("3871B3B0-2853-406B-BB61-1FE1764116FD"); inProcDataCollectionManager.TriggerTestCaseStart(testCase); inProcDataCollectionManager.TriggerTestCaseEnd(testCase, TestOutcome.Passed); inProcDataCollectionManager.TriggerTestCaseStart(testCase); inProcDataCollectionManager.TriggerTestCaseEnd(testCase, TestOutcome.Failed); var mockDataCollector = inProcDataCollectionManager.DataCollectors.Values.FirstOrDefault() as MockDataCollector; Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 2), "TestCaseStart must only be called once"); Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 2), "TestCaseEnd must only be called once"); }
public void TriggerUpdateTestResultShouldFlushIfTestCaseEndWasCalledBefore() { var inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(settingsXml, null); Assert.IsTrue(inProcDataCollectionManager.IsInProcDataCollectionEnabled, "InProcDataCollection must be enabled if runsettings contains inproc datacollectors."); Assert.AreEqual(inProcDataCollectionManager.DataCollectors.Count, 1, "One Datacollector must be registered"); var testCase = new TestCase("x.y.z", new Uri("uri://dummy"), "x.dll"); // random guid testCase.Id = new Guid("3871B3B0-2853-406B-BB61-1FE1764116FD"); var testResult = new TestResult(testCase); inProcDataCollectionManager.TriggerTestCaseStart(testCase); inProcDataCollectionManager.TriggerTestCaseEnd(testCase, TestOutcome.Passed); var allowFlush = inProcDataCollectionManager.TriggerUpdateTestResult(testResult); var mockDataCollector = inProcDataCollectionManager.DataCollectors.Values.FirstOrDefault() as MockDataCollector; Assert.IsTrue((mockDataCollector.TestCaseStartCalled == 1), "TestCaseStart must be called on datacollector"); Assert.IsTrue((mockDataCollector.TestCaseEndCalled == 1), "TestCaseEnd must be called on datacollector"); Assert.IsTrue(allowFlush, "TestResult must be flushed"); }