Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class TestPluginCache
/// <summary>
/// Initializes a new instance of the <see cref="TestPluginCache"/> class.
/// </summary>
protected TestPluginCache()
public TestPluginCache()
Comment thread
Evangelink marked this conversation as resolved.
Outdated
{
_filterableExtensionPaths = new List<string>();
_unfilterableExtensionPaths = new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class InProcDataCollectionExtensionManager

private readonly IDataCollectionSink _inProcDataCollectionSink;
private readonly string? _defaultCodeBase;
private readonly List<string?> _codeBasePaths;
internal readonly HashSet<string?> CodeBasePaths;
Comment thread
Evangelink marked this conversation as resolved.
Outdated
private readonly IFileHelper _fileHelper;

internal IDictionary<string, IInProcDataCollector> InProcDataCollectors;
Expand Down Expand Up @@ -61,13 +61,13 @@ protected InProcDataCollectionExtensionManager(string? runSettings, ITestEventsP
_inProcDataCollectionSink = new InProcDataCollectionSink();
_defaultCodeBase = defaultCodeBase;
_fileHelper = fileHelper;
_codeBasePaths = new List<string?> { _defaultCodeBase };
CodeBasePaths = new HashSet<string?> { _defaultCodeBase };
Comment thread
Evangelink marked this conversation as resolved.
Outdated
Comment thread
Evangelink marked this conversation as resolved.
Outdated

// Get Datacollector code base paths from test plugin cache
var extensionPaths = testPluginCache.GetExtensionPaths(DataCollectorEndsWithPattern);
foreach (var extensionPath in extensionPaths)
{
_codeBasePaths.Add(Path.GetDirectoryName(extensionPath)!);
CodeBasePaths.Add(Path.GetDirectoryName(extensionPath)!);
}

// Initialize InProcDataCollectors
Expand Down Expand Up @@ -248,7 +248,7 @@ private string GetCodebase(string codeBase)
return codeBase;
}

foreach (var extensionPath in _codeBasePaths)
foreach (var extensionPath in CodeBasePaths)
{
if (extensionPath is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ public InProcDataCollectionExtensionManagerTests()
_inProcDataCollectionManager = new TestableInProcDataCollectionExtensionManager(_settingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, _testPluginCache, _mockFileHelper.Object);
}

[TestMethod]
public void CheckExtensionPathsDuplicates()
Comment thread
Evangelink marked this conversation as resolved.
Outdated
{
var testPluginCache = new TestPluginCache();
Comment thread
Evangelink marked this conversation as resolved.
Outdated
testPluginCache.UpdateExtensions(new List<string> { @"c:\test1\Collector.dll" }, false);
testPluginCache.UpdateExtensions(new List<string> { @"c:\test1\Collector.dll", @"c:\test2\Collector.dll" }, true);
Comment thread
Evangelink marked this conversation as resolved.
Outdated

var inProcDataCollectionExtensionManager = new TestableInProcDataCollectionExtensionManager(_settingsXml, _mockTestEventsPublisher.Object, _defaultCodebase, testPluginCache, _mockFileHelper.Object);

Assert.AreEqual(3, inProcDataCollectionExtensionManager.CodeBasePaths.Count); // CodeBasePaths contains the two extensions(after removing Deduplicates) and the _defaultCodebase

Assert.IsTrue(inProcDataCollectionExtensionManager.CodeBasePaths.Contains(_defaultCodebase));
Comment thread
Evangelink marked this conversation as resolved.
Outdated
Assert.IsTrue(inProcDataCollectionExtensionManager.CodeBasePaths.Contains(Path.GetDirectoryName(@"c:\test1\Collector.dll")));
Assert.IsTrue(inProcDataCollectionExtensionManager.CodeBasePaths.Contains(Path.GetDirectoryName(@"c:\test2\Collector.dll")));


}
Comment thread
Evangelink marked this conversation as resolved.


[TestMethod]
public void InProcDataCollectionExtensionManagerShouldLoadsDataCollectorsFromRunSettings()
{
Expand Down