diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollecionSink.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollecionSink.cs
new file mode 100644
index 0000000000..ef9b101c1e
--- /dev/null
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollecionSink.cs
@@ -0,0 +1,102 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
+
+ //
+ internal class InProcDataCollectionSink : IDataCollectionSink
+ {
+ private IDictionary testCaseDataCollectionDataMap;
+
+ ///
+ /// In process data collection sink
+ ///
+ public InProcDataCollectionSink()
+ {
+ this.testCaseDataCollectionDataMap = new Dictionary();
+ }
+
+ //
+ public void SendData(DataCollectionContext dataCollectionContext, string key, string value)
+ {
+ ValidateArg.NotNullOrEmpty(key, "key");
+ ValidateArg.NotNullOrEmpty(value, "value");
+ ValidateArg.NotNullOrEmpty(dataCollectionContext.TestCase.Id.ToString(), "dataCollectionContext.TestCase.Id");
+
+ var testCaseId = dataCollectionContext.TestCase.Id;
+ this.AddKeyValuePairToDictionary(testCaseId, key, value);
+ }
+
+
+ ///
+ /// Gets the data collection data stored in the in process data collection sink
+ ///
+ /// valid test case id
+ /// test data collection dictionary
+ public IDictionary GetDataCollectionDataSetForTestCase(Guid testCaseId)
+ {
+ TestCaseDataCollectionData testCaseDataCollection = null;
+
+ if (!this.testCaseDataCollectionDataMap.TryGetValue(testCaseId, out testCaseDataCollection))
+ {
+ if (EqtTrace.IsWarningEnabled)
+ {
+ EqtTrace.Warning("No DataCollection Data set for the test case {0}", testCaseId);
+ }
+ return new Dictionary();
+ }
+ else
+ {
+ this.testCaseDataCollectionDataMap.Remove(testCaseId);
+ return testCaseDataCollection.CollectionData;
+ }
+ }
+
+ private void AddKeyValuePairToDictionary(Guid testCaseId, string key, string value)
+ {
+ if (!this.testCaseDataCollectionDataMap.ContainsKey(testCaseId))
+ {
+ var testCaseCollectionData = new TestCaseDataCollectionData();
+ testCaseCollectionData.AddOrUpdateData(key, value);
+ this.testCaseDataCollectionDataMap[testCaseId] = testCaseCollectionData;
+
+ }
+ else
+ {
+ this.testCaseDataCollectionDataMap[testCaseId].AddOrUpdateData(key, value);
+ }
+ }
+
+ private class TestCaseDataCollectionData
+ {
+ public TestCaseDataCollectionData()
+ {
+ this.CollectionData = new Dictionary();
+ }
+
+ internal IDictionary CollectionData { get; private set; }
+
+ internal void AddOrUpdateData(string key, string value)
+ {
+ if (!this.CollectionData.ContainsKey(key))
+ {
+ this.CollectionData[key] = value;
+ }
+ else
+ {
+ if (EqtTrace.IsWarningEnabled)
+ {
+ EqtTrace.Warning("The data for inprocdata collector with key {0} has already been set. Will be reset with new value", key);
+ }
+ this.CollectionData[key] = value;
+ }
+ }
+ }
+ }
+}
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/InProcDataCollectionExtensionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs
similarity index 70%
rename from src/Microsoft.TestPlatform.CrossPlatEngine/Execution/InProcDataCollectionExtensionManager.cs
rename to src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs
index 76571829d5..2c22f9e11c 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/InProcDataCollectionExtensionManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
-namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution
+namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection
{
using System;
using System.Collections.Generic;
@@ -17,6 +17,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
using ObjectModel.DataCollector.InProcDataCollector;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine;
+ using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection;
///
/// The in process data collection extension manager.
@@ -24,16 +25,22 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution
public class InProcDataCollectionExtensionManager
{
private IDictionary inProcDataCollectors;
+ private IDataCollectionSink inProcDataCollectionSink;
+ private IDictionary> inProcDataSinkDict;
public InProcDataCollectionExtensionManager()
{
- this.inProcDataCollectors = new Dictionary();
+ this.inProcDataCollectors = new Dictionary();
+ this.inProcDataCollectionSink = new InProcDataCollectionSink();
+ this.inProcDataSinkDict = new Dictionary>();
}
public InProcDataCollectionExtensionManager(string runsettings)
{
this.inProcDataCollectors = new Dictionary();
InProcDataCollectionUtilities.ReadInProcDataCollectionRunSettings(runsettings);
+ this.inProcDataCollectionSink = new InProcDataCollectionSink();
+ this.inProcDataSinkDict = new Dictionary>();
this.InitializeInProcDataCollectors();
}
@@ -65,9 +72,11 @@ public void InitializeInProcDataCollectors()
var type =
assembly?.GetTypes()
.FirstOrDefault(x => (x.AssemblyQualifiedName.Equals(inProcDc.AssemblyQualifiedName) && interfaceType.GetTypeInfo().IsAssignableFrom(x)));
- if (type != null && !this.inProcDataCollectors.ContainsKey(type.AssemblyQualifiedName))//this.inProcDataCollectionTypes.Contains(type)
+ if (type != null && !this.inProcDataCollectors.ContainsKey(type.AssemblyQualifiedName))
{
- this.inProcDataCollectors[type.AssemblyQualifiedName] = CreateObjectFromType(type);
+ var obj = CreateObjectFromType(type);
+ InvokeInitializeOnInProcDataCollector(obj, this.inProcDataCollectionSink);
+ this.inProcDataCollectors[type.AssemblyQualifiedName] = obj;
}
}
}
@@ -76,7 +85,7 @@ public void InitializeInProcDataCollectors()
{
EqtTrace.Error("Error occured while Initializing the datacollectors : {0}", ex);
}
- }
+ }
///
/// The trigger session start.
@@ -87,8 +96,6 @@ public virtual void TriggerTestSessionStart()
this.TriggerInProcDataCollectionMethods(Constants.TestSessionStartMethodName, testSessionStartArgs);
}
-
-
///
/// The trigger session end.
///
@@ -113,10 +120,20 @@ public virtual void TriggerTestCaseStart(TestCase testCase)
///
public virtual void TriggerTestCaseEnd(TestCase testCase, TestOutcome outcome)
{
- var testCaseEndArgs = new TestCaseEndArgs(testCase, outcome);
+ var dataCollectionContext = new DataCollectionContext(testCase);
+ var testCaseEndArgs = new TestCaseEndArgs(dataCollectionContext, outcome);
this.TriggerInProcDataCollectionMethods(Constants.TestCaseEndMethodName, testCaseEndArgs);
}
+ ///
+ /// Triggers the send test result method
+ ///
+ ///
+ public virtual void TriggerUpdateTestResult(TestResult testResult)
+ {
+ this.SetInProcDataCollectionDataInTestResult(testResult);
+ }
+
///
/// Loads the assembly into the default context based on the codebase path
///
@@ -126,7 +143,7 @@ private Assembly LoadInProcDataCollectorExtension(string codeBase)
{
Assembly assembly = null;
try
- {
+ {
#if NET46
assembly = Assembly.LoadFrom(codeBase);
#else
@@ -154,6 +171,12 @@ private static object CreateObjectFromType(Type type)
return obj;
}
+ private static void InvokeInitializeOnInProcDataCollector(object obj, IDataCollectionSink inProcDataCollectionSink)
+ {
+ var initializeMethodInfo = GetMethodInfoFromType(obj.GetType(), "Initialize", new Type[] { typeof(IDataCollectionSink) });
+ initializeMethodInfo.Invoke(obj, new object[] { inProcDataCollectionSink });
+ }
+
private static MethodInfo GetMethodInfoFromType(Type type, string funcName, Type[] argumentTypes)
{
MethodInfo methodInfo = null;
@@ -179,11 +202,11 @@ private void TriggerInProcDataCollectionMethods(string methodName, InProcDataCol
x => x.AssemblyQualifiedName.Equals(entry.Key))?
.Configuration.OuterXml;
testSessionStartArgs.Configuration = config;
- methodInfo?.Invoke(entry.Value, new[] { testSessionStartArgs });
+ methodInfo?.Invoke(entry.Value, new object[] { testSessionStartArgs });
}
else
{
- methodInfo?.Invoke(entry.Value, new[] { methodArg });
+ methodInfo?.Invoke(entry.Value, new object[] { methodArg });
}
}
}
@@ -192,6 +215,28 @@ private void TriggerInProcDataCollectionMethods(string methodName, InProcDataCol
EqtTrace.Error("Error occured while Triggering the {0} method : {1}", methodName, ex);
}
}
+
+ ///
+ /// Set the data sent via datacollection sink in the testresult property for upstream applications to read.
+ /// And removes the data from the dictionary.
+ ///
+ ///
+ private void SetInProcDataCollectionDataInTestResult(TestResult testResult)
+ {
+ //Loops through each datacollector reads the data collection data and sets as TestResult property.
+ foreach (var entry in this.inProcDataCollectors)
+ {
+ var dataCollectionData =
+ ((InProcDataCollectionSink)this.inProcDataCollectionSink).GetDataCollectionDataSetForTestCase(
+ testResult.TestCase.Id);
+
+ foreach (var keyValuePair in dataCollectionData)
+ {
+ var testProperty = TestProperty.Register(id: keyValuePair.Key, label: keyValuePair.Key, category: string.Empty, description: string.Empty, valueType: typeof(string), validateValueCallback: null, attributes: TestPropertyAttributes.None, owner: typeof(TestCase));
+ testResult.SetPropertyValue(testProperty, keyValuePair.Value);
+ }
+ }
+ }
}
public static class Constants
@@ -215,6 +260,5 @@ public static class Constants
/// The test case end method name.
///
public const string TestCaseEndMethodName = "TestCaseEnd";
-
}
}
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs
index c902d330cf..8baf2b6b5c 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/EventHandlers/TestCaseEventsHandler.cs
@@ -1,15 +1,16 @@
namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.EventHandlers
{
-
+
using System;
+
+ using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection;
#if !NET46
using System.Runtime.Loader;
#endif
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution;
-
- using TestPlatform.ObjectModel;
- using TestPlatform.ObjectModel.Engine;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine;
///
/// The test case events handler.
@@ -18,7 +19,6 @@ internal class TestCaseEventsHandler : ITestCaseEventsHandler
{
private InProcDataCollectionExtensionManager inProcDataCollectionExtensionManager;
-
private ITestCaseEventsHandler testCaseEvents;
///
@@ -68,6 +68,7 @@ public void SendTestCaseEnd(TestCase testCase, TestOutcome outcome)
///
public void SendTestResult(TestResult result)
{
+ this.inProcDataCollectionExtensionManager.TriggerUpdateTestResult(result);
this.testCaseEvents?.SendTestResult(result);
}
}
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs
index 986f860cda..0d5c72cd67 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/ExecutionManager.cs
@@ -12,6 +12,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution
using Microsoft.VisualStudio.TestPlatform.Common.Interfaces;
using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
+ using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.EventHandlers;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs
index c66cb0e6af..b78da682fe 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/DataCollectionContext.cs
@@ -2,6 +2,8 @@
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection
{
+ using System;
+
///
/// Class representing the context in which data collection occurs.
///
@@ -29,6 +31,15 @@ public class DataCollectionContext
// have public constructors. This will allow them to instantiate their
// class and pass to us for creating data collection events.
+ ///
+ /// Constructs DataCollection Context for in process data collectors
+ ///
+ /// test case to identify the context
+ public DataCollectionContext(TestCase testCase)
+ {
+ this.TestCase = testCase;
+ }
+
///
/// Constructs a DataCollectionContext indicating that there is a session,
/// but no executing test, in context.
@@ -55,11 +66,15 @@ protected internal DataCollectionContext(SessionId sessionId, TestExecId testExe
this.testExecId = testExecId;
this.hashCode = ComputeHashCode();
}
-
#endregion
#region Properties
+ ///
+ /// Gets test case.
+ ///
+ public TestCase TestCase { get; private set; }
+
///
/// Identifies the session under which the data collection occurs. Will not be null.
///
diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectionSink.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectionSink.cs
new file mode 100644
index 0000000000..522d7f523e
--- /dev/null
+++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectionSink.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection
+{
+ ///
+ /// Class used by data collectors to send data to up-stream components
+ /// (agent, controller, client, etc).
+ ///
+ public interface IDataCollectionSink
+ {
+ ///
+ /// The send data will send the data collection data to upstream applications.
+ /// Key will be set as TestProperty in TestResult and value as corresponding value.
+ ///
+ ///
+ /// The data collection context.
+ ///
+ ///
+ /// The key should be unique for a data collector.
+ ///
+ ///
+ /// The value should be a string or an object serialized into a JSON string.
+ ///
+ void SendData(DataCollectionContext dataCollectionContext, string key, string value);
+
+ }
+}
diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs
index a4b66d7ce3..77fa8cc5f5 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/InProcDataCollector.cs
@@ -11,6 +11,12 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector
///
public interface InProcDataCollection
{
+ ///
+ /// Initializes the In Process DataCollection with the DataCollectionSink
+ ///
+ /// data collection sink object
+ void Initialize(IDataCollectionSink dataCollectionSink);
+
///
/// Called when test session starts
///
diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs
index a55f95fbf1..c7835de009 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs
@@ -2,6 +2,8 @@
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector
{
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
+
///
/// The test case end args.
///
@@ -10,26 +12,26 @@ public class TestCaseEndArgs : InProcDataCollectionArgs
///
/// Initializes a new instance of the class.
///
- ///
- /// The test case.
+ ///
+ /// The data Collection Context.
///
///
/// The outcome.
///
- public TestCaseEndArgs(TestCase testCase, TestOutcome outcome)
+ public TestCaseEndArgs(DataCollectionContext dataCollectionContext, TestOutcome outcome)
{
- this.TestCase = testCase;
this.TestOutcome = outcome;
+ this.DataCollectionContext = dataCollectionContext;
}
///
- /// Gets the test case.
+ /// Gets the outcome.
///
- public TestCase TestCase { get; private set; }
+ public TestOutcome TestOutcome { get; private set; }
///
- /// Gets the outcome.
+ /// Gets the data collection context.
///
- public TestOutcome TestOutcome { get; private set; }
+ public DataCollectionContext DataCollectionContext { get; private set; }
}
}
diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/InProcDataCollectionExtensionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs
similarity index 77%
rename from test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/InProcDataCollectionExtensionManagerTests.cs
rename to test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs
index 6684da3607..c48ae1845d 100644
--- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/InProcDataCollectionExtensionManagerTests.cs
+++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs
@@ -14,6 +14,7 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Execution
using Moq;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+ using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection;
[TestClass]
public class InProcDataCollectionExtensionManagerTests
@@ -33,21 +34,29 @@ public void InitializeTests()
}
[TestMethod]
- public void InProcDataCollectionTestCaseEventHandlerCallingTriggerTestCaseStart()
+ public void TriggerTestCaseStartShouldBeCalledWhenSendTestCaseStartIsCalled()
{
this.testCasesEventsHandler.SendTestCaseStart(null);
this.mockInProcDataCollectionHelper.Verify(x => x.TriggerTestCaseStart(null), Times.Once);
}
[TestMethod]
- public void InProcDataCollectionTestCaseEventHandlerCallingTriggerTestCaseEnd()
+ public void TriggerTestCaseEndShouldBeCalledWhenSendTestCaseEndIsCalled()
{
this.testCasesEventsHandler.SendTestCaseEnd(null, TestOutcome.Passed);
this.mockInProcDataCollectionHelper.Verify(x => x.TriggerTestCaseEnd(null, TestOutcome.Passed), Times.Once);
}
[TestMethod]
- public void InProcDataCollectionTestCaseEventHandlerCallingTestCaseEventsFromClients()
+ [TestCategory("InPRocDC")]
+ public void TriggerUpdateTestResultShouldBeCalledWhenSendTestResultIsCalled()
+ {
+ this.testCasesEventsHandler.SendTestResult(null);
+ this.mockInProcDataCollectionHelper.Verify(x => x.TriggerUpdateTestResult(null), Times.Once);
+ }
+
+ [TestMethod]
+ public void TestCaseEventsFromClientsShouldBeCalledWhenTestCaseEventsAreCalled()
{
this.testCasesEventsHandler.SendTestCaseStart(null);
this.testCasesEventsHandler.SendTestCaseEnd(null, TestOutcome.Passed);
diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionSinkTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionSinkTests.cs
new file mode 100644
index 0000000000..05d4f42c83
--- /dev/null
+++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionSinkTests.cs
@@ -0,0 +1,85 @@
+
+namespace TestPlatform.CrossPlatEngine.UnitTests.DataCollection
+{
+ using System;
+
+ using Castle.DynamicProxy.Generators.Emitters;
+
+ using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ using TestPlatform.CrossPlatEngine.UnitTests.Discovery;
+
+ [TestClass]
+ public class InProcDataCollectionSinkTests
+ {
+ private IDataCollectionSink dataCollectionSink;
+
+ private DataCollectionContext dataCollectionContext;
+
+ private TestCase testCase;
+
+ [TestInitialize]
+ public void InitializeTest()
+ {
+ this.dataCollectionSink = new InProcDataCollectionSink();
+ this.testCase = new TestCase("DummyNS.DummyC.DummyM", new Uri("executor://mstest/v1"), "Dummy.dll");
+ this.dataCollectionContext = new DataCollectionContext(this.testCase);
+ }
+
+ [TestMethod]
+ public void SendDataShouldAddKeyValueToDictionaryInSink()
+ {
+ this.testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid());
+ this.dataCollectionSink.SendData(this.dataCollectionContext, "DummyKey", "DummyValue");
+
+ var dict = ((InProcDataCollectionSink)this.dataCollectionSink).GetDataCollectionDataSetForTestCase(this.testCase.Id);
+
+ Assert.AreEqual(dict["DummyKey"].ToString(), "DummyValue");
+ }
+
+ [TestMethod]
+
+ public void SendDataShouldThrowArgumentExceptionIfKeyIsNull()
+ {
+ this.testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid());
+
+ Assert.ThrowsException(
+ () => this.dataCollectionSink.SendData(this.dataCollectionContext, null, "DummyValue"));
+ }
+
+ [TestMethod]
+ public void SendDataShouldThrowArgumentExceptionIfValueIsNull()
+ {
+ this.testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid());
+
+ Assert.ThrowsException(
+ () => this.dataCollectionSink.SendData(this.dataCollectionContext, "DummyKey", null));
+ }
+
+ [TestMethod]
+ [Ignore]
+
+ // TODO : Currently this code hits when test case id is null for core projects. For that we don't have algorithm to generate the guid. It's not implemented exception now (Source Code : EqtHash.cs).
+ public void SendDataShouldThrowArgumentExceptionIfTestCaseIdIsNull()
+ {
+ Assert.ThrowsException(
+ () => this.dataCollectionSink.SendData(this.dataCollectionContext, "DummyKey", "DummyValue"));
+ }
+
+ [TestMethod]
+ public void GetDataCollectionDataSetForTestCaseShouldRemoveTestCaseAfterRetunredTheData()
+ {
+ this.testCase.SetPropertyValue(TestCaseProperties.Id, Guid.NewGuid());
+ this.dataCollectionSink.SendData(this.dataCollectionContext, "DummyKey", "DummyValue");
+
+ var dict = ((InProcDataCollectionSink)this.dataCollectionSink).GetDataCollectionDataSetForTestCase(this.testCase.Id);
+ Assert.AreEqual(dict["DummyKey"].ToString(), "DummyValue");
+
+ var emptyDict = ((InProcDataCollectionSink)this.dataCollectionSink).GetDataCollectionDataSetForTestCase(this.testCase.Id);
+ Assert.AreEqual(emptyDict.Keys.Count, 0);
+ }
+ }
+}