Skip to content

Commit

Permalink
Data collector cleanup (microsoft#1264)
Browse files Browse the repository at this point in the history
* Data Collector Cleanup

* Fixed test.

* Removed property TargetDataCollectorUri
  • Loading branch information
harshjain2 authored Nov 28, 2017
1 parent 5aaae53 commit 95f06ae
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void TestCaseStarted(TestCaseStartEventArgs testCaseStartEventArgs)
return;
}

var context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, new TestExecId(testCaseStartEventArgs.TestCaseId));
var context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, testCaseStartEventArgs.TestElement);
testCaseStartEventArgs.Context = context;

this.SendEvent(testCaseStartEventArgs);
Expand All @@ -287,7 +287,7 @@ public Collection<AttachmentSet> TestCaseEnded(TestCaseEndEventArgs testCaseEndE
return new Collection<AttachmentSet>();
}

var context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, new TestExecId(testCaseEndEventArgs.TestCaseId));
var context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, testCaseEndEventArgs.TestElement);
testCaseEndEventArgs.Context = context;

this.SendEvent(testCaseEndEventArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public DataCollectionContext(TestCase testCase)
/// </summary>
/// <param name="sessionId">The session under which the data collection occurs. Cannot be null.</param>
protected internal DataCollectionContext(SessionId sessionId)
: this(sessionId, null)
: this(sessionId, (TestExecId)null)
{
}

Expand All @@ -66,6 +66,12 @@ protected internal DataCollectionContext(SessionId sessionId, TestExecId testExe
this.testExecId = testExecId;
this.hashCode = ComputeHashCode();
}

protected internal DataCollectionContext(SessionId sessionId, TestCase testCase) : this(sessionId, new TestExecId(testCase.Id))
{
this.TestCase = testCase;

}
#endregion

#region Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,6 @@ public virtual void LogException(DataCollectionContext context, Exception ex, Da
{
}

/// <summary>
/// Sends custom data from the collector
/// </summary>
/// <param name="context">Context under which the data collection is happening</param>
/// <param name="matchingEventArgs">Custom notification arguments to which the data is being sent in respose to.</param>
/// <param name="data">Custom data to be sent</param>
/// <remarks>
/// When a Data Collector invokes this method, Client would get called on OnCollectionData( ) with a CollectionDataMessageEventArgs.
/// The datacollectioncontext of the matchingeventargs will be used for sending the data.
/// </remarks>
public virtual void SendData(CustomNotificationEventArgs matchingEventArgs, CustomCollectorData data)
{
// Default no-op.
}

/// <summary>
/// Sends custom data from the collector
/// </summary>
/// <param name="context">Context under which the data collection is happening</param>
/// <param name="data">Custom data to be sent</param>
/// <remarks>
/// When a Data Collector invokes this method, Client would get called on OnCollectionException( ) with a CollectionExceptionMessageEventArgs.
/// </remarks>
public virtual void SendData(DataCollectionContext context, CustomCollectorData data)
{
// Default no-op.
}

#endregion
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection
/// Base class for all execution event arguments
/// </summary>
#if NET451
[Serializable]
[Serializable]
#endif
public abstract class DataCollectionEventArgs : EventArgs
{
Expand All @@ -27,17 +27,9 @@ public DataCollectionEventArgs()
/// Initializes the instance by storing the given information
/// </summary>
/// <param name="context">Context information for the event</param>
protected DataCollectionEventArgs(DataCollectionContext context) :
this(context, null)
protected DataCollectionEventArgs(DataCollectionContext context)
{
}

protected DataCollectionEventArgs(DataCollectionContext context, Uri targetDataCollectorUri)
{
//EqtTrace.FailIf(context == null, "Context should not be null.");

Context = context;
TargetDataCollectorUri = targetDataCollectorUri;
}

#endregion
Expand All @@ -53,15 +45,6 @@ public DataCollectionContext Context
internal set;
}

/// <summary>
/// Gets or sets Data collector Uri this notification is targeted for
/// </summary>
public Uri TargetDataCollectorUri
{
get;
set;
}

#endregion

#region Private Methods
Expand Down
1 change: 1 addition & 0 deletions test/datacollector.UnitTests/DataCollectionManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ public void TestCaseEndedShouldSendEventToDataCollector()

this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings);
var args = new TestCaseEndEventArgs();
args.TestElement = new TestCase();
this.dataCollectionManager.TestCaseEnded(args);

Assert.IsTrue(isEndInvoked);
Expand Down

0 comments on commit 95f06ae

Please sign in to comment.