diff --git a/TestPlatform.sln b/TestPlatform.sln index 16600ead40..a3190a0116 100644 --- a/TestPlatform.sln +++ b/TestPlatform.sln @@ -83,6 +83,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "datacollector", "src\dataco EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "datacollector.x86", "src\datacollector.x86\datacollector.x86.xproj", "{00DFB5C7-3850-4A65-986B-713F200482D4}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "datacollector.x86.UnitTests", "test\datacollector.x86.UnitTests\datacollector.x86.UnitTests.xproj", "{00AA21F3-31E4-4748-AC0B-C4EADB41CA24}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -205,6 +207,10 @@ Global {00DFB5C7-3850-4A65-986B-713F200482D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {00DFB5C7-3850-4A65-986B-713F200482D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {00DFB5C7-3850-4A65-986B-713F200482D4}.Release|Any CPU.Build.0 = Release|Any CPU + {00AA21F3-31E4-4748-AC0B-C4EADB41CA24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00AA21F3-31E4-4748-AC0B-C4EADB41CA24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00AA21F3-31E4-4748-AC0B-C4EADB41CA24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00AA21F3-31E4-4748-AC0B-C4EADB41CA24}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -241,5 +247,6 @@ Global {0CC51428-B665-47B0-A093-042D31785928} = {707096D0-DCFB-44A2-979D-178740E5DADE} {3572E78C-5AA5-4F68-876D-FC5322677263} = {D8EF073C-279A-4279-912D-E9D4B0635E17} {00DFB5C7-3850-4A65-986B-713F200482D4} = {D8EF073C-279A-4279-912D-E9D4B0635E17} + {00AA21F3-31E4-4748-AC0B-C4EADB41CA24} = {463031A2-7F16-4E38-9944-1F5161D04933} EndGlobalSection EndGlobal diff --git a/dogfood/UnitTestProject/project.json b/dogfood/UnitTestProject/project.json index dd923ed714..4e2d3f5085 100644 --- a/dogfood/UnitTestProject/project.json +++ b/dogfood/UnitTestProject/project.json @@ -14,7 +14,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" } } }, diff --git a/src/Microsoft.TestPlatform.Client/project.json b/src/Microsoft.TestPlatform.Client/project.json index 8f0e29c399..edfc63a97d 100644 --- a/src/Microsoft.TestPlatform.Client/project.json +++ b/src/Microsoft.TestPlatform.Client/project.json @@ -20,7 +20,7 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008" + "NETStandard.Library": "1.6.0" } }, "net46": { } diff --git a/src/Microsoft.TestPlatform.Common/project.json b/src/Microsoft.TestPlatform.Common/project.json index 699917ca1a..be88cd7f09 100644 --- a/src/Microsoft.TestPlatform.Common/project.json +++ b/src/Microsoft.TestPlatform.Common/project.json @@ -18,7 +18,7 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008", + "NETStandard.Library": "1.6.0", "System.Runtime.Loader": "4.0.0-rc2-24027" } }, diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/project.json b/src/Microsoft.TestPlatform.CommunicationUtilities/project.json index a6f18faafc..9a50f03550 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/project.json +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/project.json @@ -20,7 +20,7 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008", + "NETStandard.Library": "1.6.0", "System.Runtime.Serialization.Primitives": "4.0.10-*" } }, diff --git a/src/Microsoft.TestPlatform.CoreUtilities/project.json b/src/Microsoft.TestPlatform.CoreUtilities/project.json index ec6e84aec6..7b6ea0e7ad 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/project.json +++ b/src/Microsoft.TestPlatform.CoreUtilities/project.json @@ -13,7 +13,7 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008" + "NETStandard.Library": "1.6.0" } }, "net46": { diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/project.json b/src/Microsoft.TestPlatform.CrossPlatEngine/project.json index ac845d8980..4fe4b92dcf 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/project.json +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/project.json @@ -20,9 +20,9 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008", + "NETStandard.Library": "1.6.0", "System.Diagnostics.Process": "4.1.0-rc2-23704", - "System.Threading": "4.0.11-rc2-24027" + "System.Threading": "4.0.11" } }, "net46": {} diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/project.json b/src/Microsoft.TestPlatform.Extensions.TrxLogger/project.json index 15e32a27b2..739e003559 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/project.json +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/project.json @@ -20,10 +20,10 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008", - "System.Collections.NonGeneric": "4.0.1-rc2-24027", + "NETStandard.Library": "1.6.0", + "System.Collections.NonGeneric": "4.0.1", "System.Security.Principal.Windows": "4.0.0-rc2-24027", - "System.Collections.Specialized": "4.0.1-rc2-24027" + "System.Collections.Specialized": "4.0.1" } }, "net46": { } diff --git a/src/Microsoft.TestPlatform.ObjectModel/CustomGuidConverter.cs b/src/Microsoft.TestPlatform.ObjectModel/CustomGuidConverter.cs new file mode 100644 index 0000000000..a5278384b1 --- /dev/null +++ b/src/Microsoft.TestPlatform.ObjectModel/CustomGuidConverter.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.VisualStudio.TestPlatform.ObjectModel +{ + using System; + using System.ComponentModel; + using System.Globalization; + + /// + /// Custom Guid converter class + /// + internal class CustomGuidConverter : GuidConverter + { + /// + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if(destinationType == typeof(Guid)) + { + return new Guid(value.ToString()); + } + return base.ConvertTo(context, culture, value, destinationType); + } + } +} diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs b/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs index a396116679..cfc164a144 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft. All rights reserved. namespace Microsoft.VisualStudio.TestPlatform.ObjectModel { @@ -76,7 +76,8 @@ protected TestObject() public TestObject() #endif { - this.store = new Dictionary(); + this.store = new Dictionary(); + TypeDescriptor.AddAttributes(typeof(Guid), new TypeConverterAttribute(typeof(CustomGuidConverter))); } [OnSerializing] @@ -101,9 +102,9 @@ public void CacheLazyValuesOnSerializing(StreamingContext context) } } - #endregion Constructors +#endregion Constructors - #region Properties +#region Properties /// /// Returns the TestProperties currently specified in this TestObject. @@ -233,9 +234,9 @@ public void SetPropertyValue(TestProperty property, LazyPropertyValue valu PrivateSetPropertyValue(property, objValue); } - #endregion Property Values +#endregion Property Values - #region Helpers +#region Helpers /// /// Return TestProperty's value /// @@ -355,7 +356,7 @@ private static T ConvertPropertyTo(TestProperty property, CultureInfo culture } } - #endregion Helpers +#endregion Helpers private TraitCollection traits; @@ -371,5 +372,5 @@ public TraitCollection Traits return this.traits; } } - } -} + } +} \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/project.json b/src/Microsoft.TestPlatform.ObjectModel/project.json index 08ef10b35e..622c76a107 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/project.json +++ b/src/Microsoft.TestPlatform.ObjectModel/project.json @@ -1,7 +1,7 @@ { "version": "15.0.0-*", "buildOptions": { - "outputName": "Microsoft.VisualStudio.TestPlatform.ObjectModel", + //"outputName": "Microsoft.VisualStudio.TestPlatform.ObjectModel", "delaySign": true, "keyFile": "../../scripts/key.snk", "warningsAsErrors": true @@ -26,14 +26,14 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008", + "NETStandard.Library": "1.6.0", "System.Runtime.Serialization.Primitives": "4.0.10", - "System.Runtime.Extensions": "4.1.0-rc3-23808", + "System.Runtime.Extensions": "4.1.0", "System.Xml.XPath.XmlDocument": "4.0.1-rc2-24027", "System.ComponentModel.EventBasedAsync": "4.0.11-rc2-24018", - "System.Runtime.InteropServices": "4.1.0-rc2-24027", - "System.IO.FileSystem": "4.0.1-rc3-23808", - "System.ComponentModel.TypeConverter": "4.0.1-rc2-23911" + "System.Runtime.InteropServices": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.ComponentModel.TypeConverter": "4.1.0" } } } diff --git a/src/Microsoft.TestPlatform.Utilities/project.json b/src/Microsoft.TestPlatform.Utilities/project.json index 4444d1889f..d8e79b35c2 100644 --- a/src/Microsoft.TestPlatform.Utilities/project.json +++ b/src/Microsoft.TestPlatform.Utilities/project.json @@ -26,7 +26,7 @@ "portable-net45+wp80+win8+wpa81+dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008" + "NETStandard.Library": "1.6.0" } }, "net46": { } diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/project.json b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/project.json index a2f8c5788b..f4f6cf11aa 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/project.json +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/project.json @@ -13,17 +13,17 @@ "portable-net45+win8" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24008", + "NETStandard.Library": "1.6.0", "System.Runtime.Serialization.Primitives": "4.0.10", - "System.Runtime.Extensions": "4.1.0-rc3-23808", + "System.Runtime.Extensions": "4.1.0", "System.Xml.XPath.XmlDocument": "4.0.1-rc2-24027", "System.ComponentModel.EventBasedAsync": "4.0.11-rc2-24018", - "System.Runtime.InteropServices": "4.1.0-rc2-24027", - "System.IO.FileSystem": "4.0.1-rc3-23808", - "System.ComponentModel.TypeConverter": "4.0.1-rc2-23911", + "System.Runtime.InteropServices": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.ComponentModel.TypeConverter": "4.1.0", "System.Diagnostics.Process": "4.1.0-rc2-23704", "Microsoft.TestPlatform.CommunicationUtilities": "15.0.0-*", - "Microsoft.TestPlatform.ObjectModel": "15.0.0-*", + "Microsoft.TestPlatform.ObjectModel": "15.0.0-*" } }, "net46": { @@ -33,7 +33,7 @@ }, "dependencies": { "Microsoft.TestPlatform.CommunicationUtilities": "15.0.0-*", - "Microsoft.TestPlatform.ObjectModel": "15.0.0-*", + "Microsoft.TestPlatform.ObjectModel": "15.0.0-*" } } } diff --git a/src/datacollector.x86/DataCollectionCoordinator.cs b/src/datacollector.x86/DataCollectionCoordinator.cs new file mode 100644 index 0000000000..c1d2b70a8c --- /dev/null +++ b/src/datacollector.x86/DataCollectionCoordinator.cs @@ -0,0 +1,232 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.VisualStudio.TestPlatform.DataCollector +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Threading.Tasks; + + using Microsoft.VisualStudio.TestPlatform.DataCollector.Interfaces; + using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.Common; + using Microsoft.VisualStudio.TestPlatform.Common.Utilities; + + /// + /// Coordinates the Data Collection for V1 and V2 DataCollectors + /// + internal class DataCollectionCoordinator : IDisposable + { + private IDataCollectionManager[] dataCollectionManagers; + private bool disposed; + + /// + /// Initializes a new instance of the class. + /// + public DataCollectionCoordinator() : this(default(IDataCollectionManager[])) + { + } + + /// + /// Constructor with Dependency injection. Used for unit testing. + /// + /// Array of IDataCollectionManagers for handling various versions of DataCollectors (Legacy,V2) + internal DataCollectionCoordinator(IDataCollectionManager[] dataCollectionManagers) + { + this.dataCollectionManagers = dataCollectionManagers; + } + + /// + /// Invoked before starting of test run. + /// + /// Specifies the settings which are being used for the run. + /// Forces the data collectors to be reset. + /// Specifies whether run is going to start immediately. + /// Enivronment variables for the executor. + public BeforeTestRunStartResult BeforeTestRunStart(string settingsXml, bool resetDataCollectors, bool isRunStartingNow) + { + if (this.dataCollectionManagers == null || this.dataCollectionManagers.Length == 0) + { + return null; + } + + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DataCollectionCoordinator: BeforeTestRunStart Entering."); + } + + var runSettings = RunSettingsUtilities.CreateAndInitializeRunSettings(settingsXml); + + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DataCollectionCoordinator: Loading/Initializing the data collectors"); + } + + // Load the collectors and get the environment variables + var environmentVariables = this.LoadDataCollectors(runSettings); + + var areTestCaseLevelEventsRequired = false; + + if (isRunStartingNow) + { + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DataCollectionCoordinator: Raising session started event."); + } + + // Raise SessionStart event to loaded data collection plugins. + areTestCaseLevelEventsRequired = this.SessionStarted(); + } + + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DataCollectionCoordinator: BeforeTestRunStart Exiting areTestCaseLevelEventsRequired={0}.", areTestCaseLevelEventsRequired); + } + + // todo : Get Data Collection Port here + return new BeforeTestRunStartResult(environmentVariables, areTestCaseLevelEventsRequired, 0); + } + + /// + /// Invoked after ending of test run. + /// + /// Specified whether the test run is cancelled. + /// Collection of session attachmentsets. + public Collection AfterTestRunEnd(bool isCancelled) + { + if (this.dataCollectionManagers == null || this.dataCollectionManagers.Length == 0) + { + return null; + } + + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DataCollectionCoordinator.AfterTestRunEnd: Entering."); + } + + // Send RunCompleteEvent to data collection plugin manager so it can raise session end event to loaded collector plugins. + Collection result = this.SessionEnded(isCancelled); + + if (EqtTrace.IsVerboseEnabled) + { + EqtTrace.Verbose("DataCollectionCoordinator.AfterTestRunEnd: Exiting."); + } + + return result; + } + + /// + /// The dispose. + /// + public void Dispose() + { + this.Dispose(true); + + // Use SupressFinalize in case a subclass + // of this type implements a finalizer. + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + if (this.dataCollectionManagers != null && this.dataCollectionManagers.Length > 0) + { + var tasks = new List(this.dataCollectionManagers.Length); + + foreach (var dataCollectionManager in this.dataCollectionManagers) + { + tasks.Add(Task.Factory.StartNew(() => dataCollectionManager.Dispose())); + } + + Task.WaitAll(tasks.ToArray()); + } + } + + this.disposed = true; + } + } + + private Dictionary LoadDataCollectors(RunSettings runSettings) + { + var envVars = new Dictionary(); + var tasks = new List>>(this.dataCollectionManagers.Length); + + foreach (var dataCollectionManager in this.dataCollectionManagers) + { + tasks.Add(Task>.Factory.StartNew(() => dataCollectionManager.LoadDataCollectors(runSettings))); + } + + Task.WaitAll(tasks.ToArray()); + + for (var i = 0; i < this.dataCollectionManagers.Length; i++) + { + if (tasks[i].Status == TaskStatus.Faulted) + { + throw tasks[i].Exception.InnerException; + } + + foreach (var kvp in tasks[i]?.Result) + { + if (!envVars.ContainsKey(kvp.Key)) + { + envVars.Add(kvp.Key, kvp.Value); + } + } + } + + return envVars; + } + + private bool SessionStarted() + { + var areTestCaseLevelEventsRequired = false; + + var tasks = new List>(this.dataCollectionManagers.Length); + + foreach (var dataCollectionManager in this.dataCollectionManagers) + { + tasks.Add(Task.Factory.StartNew(() => dataCollectionManager.SessionStarted())); + } + + Task.WaitAll(tasks.ToArray()); + + for (var i = 0; i < this.dataCollectionManagers.Length; i++) + { + areTestCaseLevelEventsRequired = areTestCaseLevelEventsRequired || tasks[i].Result; + } + + return areTestCaseLevelEventsRequired; + } + + private Collection SessionEnded(bool isCancelled) + { + var attachments = new Collection(); + var tasks = new List>>(this.dataCollectionManagers.Length); + + foreach (var dataCollectionManager in this.dataCollectionManagers) + { + tasks.Add(Task>.Factory.StartNew(() => dataCollectionManager.SessionEnded(isCancelled))); + } + + Task.WaitAll(tasks.ToArray()); + + for (var i = 0; i < this.dataCollectionManagers.Length; i++) + { + if (tasks[i].Result != null) + { + foreach (var attachment in tasks[i].Result) + { + attachments.Add(attachment); + } + } + } + + return attachments; + } + } +} diff --git a/src/datacollector.x86/Friends.cs b/src/datacollector.x86/Friends.cs new file mode 100644 index 0000000000..9a3b255746 --- /dev/null +++ b/src/datacollector.x86/Friends.cs @@ -0,0 +1,7 @@ +using System.Runtime.CompilerServices; + +#region Test Assemblies + +[assembly: InternalsVisibleTo("datacollector.x86.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] + +#endregion \ No newline at end of file diff --git a/src/datacollector.x86/Interfaces/IDataCollectionManager.cs b/src/datacollector.x86/Interfaces/IDataCollectionManager.cs new file mode 100644 index 0000000000..7e06b2f330 --- /dev/null +++ b/src/datacollector.x86/Interfaces/IDataCollectionManager.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.VisualStudio.TestPlatform.DataCollector.Interfaces +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Linq; + using System.Threading.Tasks; + + using Microsoft.VisualStudio.TestPlatform.Common; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + + /// + /// Defines the Data Collection Manager for Data Collectors. + /// + internal interface IDataCollectionManager : IDisposable + { + /// + /// Loads and initializes data collector plugins. + /// + /// Run Settings which has DataCollector configuration. + /// Environment variables. + Dictionary LoadDataCollectors(RunSettings settingsXml); + + /// + /// Raises TestCaseStart event to all data collectors configured for run. + /// + /// TestCaseStart event. + void TestCaseStarted(TestCaseStartEventArgs testCaseStartEventArgs); + + /// + /// Raises TestCaseEnd event to all data collectors configured for run. + /// + /// Test case which is complete. + /// Outcome of the test case. + /// Collection of testCase attachmentSet. + Collection TestCaseEnded(TestCase testCase, TestOutcome testOutcome); + + /// + /// Raises SessionStart event to all data collectors configured for run. + /// + /// Are test case level events required. + bool SessionStarted(); + + /// + /// Raises SessionEnd event to all data collectors configured for run. + /// + /// Specified whether the run is cancelled or not. + /// Collection of session attachmentSet. + Collection SessionEnded(bool isCancelled); + } +} \ No newline at end of file diff --git a/src/datacollector.x86/Program.cs b/src/datacollector.x86/Program.cs index 80c99e1fdb..1da4233940 100644 --- a/src/datacollector.x86/Program.cs +++ b/src/datacollector.x86/Program.cs @@ -3,9 +3,10 @@ namespace Microsoft.VisualStudio.TestPlatform.DataCollector.x86 { using System; - using Microsoft.VisualStudio.TestPlatform.ObjectModel; - using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; + using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; /// /// The program. diff --git a/src/datacollector.x86/project.json b/src/datacollector.x86/project.json index 423caa4323..ded8cc6110 100644 --- a/src/datacollector.x86/project.json +++ b/src/datacollector.x86/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "15.0.0-*", "buildOptions": { @@ -16,8 +16,8 @@ }, "runtimes": { - "win7-x64": { }, - "win7-x86": { } + "win7-x64": {}, + "win7-x86": {} }, "frameworks": { @@ -29,11 +29,13 @@ "portable-net45+wp80+win8+wpa81+dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24027", - "Microsoft.DotNet.ProjectModel": "1.0.0-rc2-002702", - "System.ComponentModel.TypeConverter": "4.0.1-rc2-23911" + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "Microsoft.DotNet.ProjectModel": "1.0.0-rc2-002702" } }, "net46": {} } -} +} \ No newline at end of file diff --git a/src/datacollector/project.json b/src/datacollector/project.json index 0d55f02ea9..304c3a76a8 100644 --- a/src/datacollector/project.json +++ b/src/datacollector/project.json @@ -7,7 +7,10 @@ "keyFile": "../../scripts/key.snk", "warningsAsErrors": true, "compile": [ - "../datacollector.x86/Program.cs" + "../datacollector.x86/Program.cs", + "../datacollector.x86/DataCollectionCoordinator.cs", + "../datacollector.x86/Interfaces/IDataCollectionManager.cs", + "../datacollector.x86/Friends.cs" ] }, @@ -18,8 +21,8 @@ }, "runtimes": { - "win7-x64": { }, - "win7-x86": { } + "win7-x64": {}, + "win7-x86": {} }, "frameworks": { @@ -31,8 +34,11 @@ "portable-net45+wp80+win8+wpa81+dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24027", - "System.ComponentModel.TypeConverter": "4.0.1-rc2-23911" + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "System.ComponentModel.TypeConverter": "4.1.0" } }, "net46": { } diff --git a/src/testhost.x86/project.json b/src/testhost.x86/project.json index 16cc8b23f3..a2829d5f37 100644 --- a/src/testhost.x86/project.json +++ b/src/testhost.x86/project.json @@ -29,8 +29,11 @@ "portable-net45+wp80+win8+wpa81+dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24027", - "System.ComponentModel.TypeConverter": "4.0.1-rc2-23911" + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "System.ComponentModel.TypeConverter": "4.1.0" } }, "net46": {} diff --git a/src/testhost/project.json b/src/testhost/project.json index 5a823092bd..dc6c7cb864 100644 --- a/src/testhost/project.json +++ b/src/testhost/project.json @@ -31,8 +31,12 @@ "portable-net45+wp80+win8+wpa81+dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24027", - "System.ComponentModel.TypeConverter": "4.0.1-rc2-23911" + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "System.ComponentModel.TypeConverter": "4.1.0", + "Microsoft.NETCore.Runtime.CoreCLR": "1.0.2" } }, "net46": {} diff --git a/src/vstest.console/project.json b/src/vstest.console/project.json index 56f45d9a60..d88fa32aa5 100644 --- a/src/vstest.console/project.json +++ b/src/vstest.console/project.json @@ -31,10 +31,13 @@ "portable-net45+wp80+win8+wpa81+dnxcore50" ], "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24027", - "System.ComponentModel.TypeConverter": "4.0.1-rc2-23911", + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "System.ComponentModel.TypeConverter": "4.1.0", "System.Diagnostics.Contracts": "4.0.0", - "System.Xml.XPath": "4.0.1-rc2-24027" + "System.Xml.XPath": "4.0.1" } }, "net46": {} diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/project.json b/test/Microsoft.TestPlatform.Client.UnitTests/project.json index 0864e1388b..57f3d781f1 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.Client.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/project.json b/test/Microsoft.TestPlatform.Common.UnitTests/project.json index 08ee5df4f7..b12ef7b3dc 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.Common.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/project.json b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/project.json index 04f02e2ca5..eca8f0460b 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/project.json b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/project.json index 7d23b7c370..6900b217a6 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/project.json b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/project.json index b89ee5ead5..35ebd037c8 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/project.json b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/project.json index bc0601c04b..eac7795cc8 100644 --- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestObjectTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestObjectTests.cs new file mode 100644 index 0000000000..4aea811ef5 --- /dev/null +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestObjectTests.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.TestPlatform.ObjectModel.UnitTests +{ + using System; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + + [TestClass] + public class TestObjectTests + { + [TestMethod] + public void TestCaseIdShouldReturnGuidWhenTestPropertiesIdIsSet() + { + TestCase testCase = new TestCase("DummyNS.DummyClass.DummyTest", new Uri("executor://mstestadapter/v1"), "C:\tests.dll"); + Guid expected = new Guid("{8167845C-9CDB-476F-9F2B-1B1C1FE01B7D}"); + testCase.SetPropertyValue(TestCaseProperties.Id, expected); + + var actual = testCase.Id; + + Assert.AreEqual(expected, actual); + } + } +} diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/project.json b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/project.json index fed3a2b673..0a55d85444 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", @@ -18,7 +18,7 @@ }, "MSTest.TestFramework": "1.0.0-preview", "moq.netcore": "4.4.0-beta8", - "System.Diagnostics.TraceSource": "4.0.0-rc2-24015", + "System.Diagnostics.TraceSource": "4.0.0-rc2-24015", "Microsoft.TestPlatform.ObjectModel": "15.0.0-*" }, diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/project.json b/test/Microsoft.TestPlatform.Utilities.UnitTests/project.json index 8dfbcbfa47..f012bd59b7 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests/project.json b/test/Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests/project.json index 15b0f62b70..cf5e667806 100644 --- a/test/Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests/project.json +++ b/test/Microsoft.TestPlatform.VsTestConsole.TranslationLayer.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/datacollector.x86.UnitTests/DataCollectionCoordinatorTests.cs b/test/datacollector.x86.UnitTests/DataCollectionCoordinatorTests.cs new file mode 100644 index 0000000000..7c7ec571ce --- /dev/null +++ b/test/datacollector.x86.UnitTests/DataCollectionCoordinatorTests.cs @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.VisualStudio.TestPlatform.DataCollector.UnitTests +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Diagnostics; + using System.Linq; + using System.Threading; + + using Microsoft.VisualStudio.TestPlatform.Common; + using Microsoft.VisualStudio.TestPlatform.DataCollector.Interfaces; + using Microsoft.VisualStudio.TestPlatform.DataCollector.x86; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class DataCollectionCoordinatorTests + { + private DummyDataCollectionManager dummyDataCollectionManagerV1, dummyDataCollectionManagerV2; + private DataCollectionCoordinator dataCollectionCoordinator; + + [TestInitialize] + public void Initialize() + { + this.dummyDataCollectionManagerV1 = new DummyDataCollectionManager(); + this.dummyDataCollectionManagerV2 = new DummyDataCollectionManager(); + this.dataCollectionCoordinator = new DataCollectionCoordinator(new[] { dummyDataCollectionManagerV1, dummyDataCollectionManagerV2 }); + } + + [TestMethod] + public void BeforeTestRunStartShouldReturnBeforeTestRunStartResult() + { + var envVars = new Dictionary(); + envVars.Add("key", "value"); + this.dummyDataCollectionManagerV1.envVariables = envVars; + this.dummyDataCollectionManagerV2.envVariables = new Dictionary(); + + var result = this.dataCollectionCoordinator.BeforeTestRunStart(settingsXml: string.Empty, resetDataCollectors: true, isRunStartingNow: true); + + Assert.IsTrue(this.dummyDataCollectionManagerV1.isLoadCollectorsInvoked); + Assert.IsTrue(this.dummyDataCollectionManagerV2.isLoadCollectorsInvoked); + Assert.IsTrue(this.dummyDataCollectionManagerV1.isSessionStartedInvoked); + Assert.IsTrue(this.dummyDataCollectionManagerV2.isSessionStartedInvoked); + Assert.AreEqual(1, result.EnvironmentVariables.Count); + Assert.AreEqual(envVars.Keys.First(), result.EnvironmentVariables.Keys.First()); + Assert.AreEqual(envVars.Values.First(), result.EnvironmentVariables.Values.First()); + } + + [TestMethod] + public void BeforeTestRunStartShouldLoadTwoDataCollectorsInParallel() + { + var envVars = new Dictionary(); + envVars.Add("key", "value"); + this.dummyDataCollectionManagerV1.envVariables = envVars; + this.dummyDataCollectionManagerV2.envVariables = new Dictionary(); + + var result = this.dataCollectionCoordinator.BeforeTestRunStart(settingsXml: string.Empty, resetDataCollectors: true, isRunStartingNow: true); + + // Verify the two collectors are invoked in parallel + Assert.IsTrue(this.dummyDataCollectionManagerV1.ThreadId > 0); + Assert.IsTrue(this.dummyDataCollectionManagerV2.ThreadId > 0); + Assert.AreNotEqual(this.dummyDataCollectionManagerV1.ThreadId, this.dummyDataCollectionManagerV2.ThreadId); + } + + [TestMethod] + public void BeforeTestRunStartShouldReturnNullIfNoDataCollectorManagersAreProvided() + { + this.dataCollectionCoordinator = new DataCollectionCoordinator(null); + + var result = this.dataCollectionCoordinator.BeforeTestRunStart(settingsXml: string.Empty, resetDataCollectors: true, isRunStartingNow: true); + + Assert.IsNull(result); + } + + [TestMethod] + public void BeforeTestRunStartShouldThrowExceptionIfExceptionIsThrownByDataCollectionManager() + { + this.dummyDataCollectionManagerV1.loadDataCollectorsThrowException = true; + + Assert.ThrowsException( + () => + { + var result = this.dataCollectionCoordinator.BeforeTestRunStart(settingsXml: string.Empty, resetDataCollectors: true, isRunStartingNow: true); + }); + } + + [TestMethod] + public void AfterTestRunEndShouldReturnAttachments() + { + Collection attachments1 = new Collection(); + AttachmentSet attachmentset1 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); + attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); + attachments1.Add(attachmentset1); + + this.dummyDataCollectionManagerV1.attachments = attachments1; + this.dummyDataCollectionManagerV2.attachments = attachments1; + + var result = this.dataCollectionCoordinator.AfterTestRunEnd(isCancelled: false); + + Assert.IsNotNull(result); + Assert.IsTrue(this.dummyDataCollectionManagerV1.isSessionEndedInvoked); + Assert.IsTrue(this.dummyDataCollectionManagerV2.isSessionEndedInvoked); + Assert.AreEqual(2, result.Count()); + } + + [TestMethod] + public void AfterTestRunEndShouldGetAttachmentsFromDataCollectorManagersInParallel() + { + Collection attachments1 = new Collection(); + AttachmentSet attachmentset1 = new AttachmentSet(new Uri("DataCollection://Attachment/v1"), "AttachmentV1"); + attachmentset1.Attachments.Add(new UriDataAttachment(new Uri("DataCollection://Attachment/v11"), "AttachmentV1-Attachment1")); + attachments1.Add(attachmentset1); + + this.dummyDataCollectionManagerV1.attachments = attachments1; + this.dummyDataCollectionManagerV2.attachments = attachments1; + + var result = this.dataCollectionCoordinator.AfterTestRunEnd(isCancelled: false); + + // Verify the two collectors are invoked in parallel + Assert.IsTrue(this.dummyDataCollectionManagerV1.ThreadId > 0); + Assert.IsTrue(this.dummyDataCollectionManagerV2.ThreadId > 0); + Assert.AreNotEqual(this.dummyDataCollectionManagerV1.ThreadId, this.dummyDataCollectionManagerV2.ThreadId); + } + + [TestMethod] + public void AfterTestRunEndShouldReturnNullIfNoDataCollectorManagersAreProvided() + { + this.dataCollectionCoordinator = new DataCollectionCoordinator(null); + + var result = this.dataCollectionCoordinator.AfterTestRunEnd(isCancelled: true); + + Assert.IsNull(result); + } + + [TestMethod] + public void AfterTestRunEndShouldThrowExceptionIfExceptionIsThrownByDataCollectionManager() + { + this.dummyDataCollectionManagerV1.sessionEndedThrowsException = true; + + Assert.ThrowsException( + () => + { + var result = this.dataCollectionCoordinator.AfterTestRunEnd(isCancelled: false); + }); + } + + [TestMethod] + public void DisposeShouldCallDisposeOfDataCollectionManagers() + { + this.dataCollectionCoordinator.Dispose(); + + Assert.IsTrue(this.dummyDataCollectionManagerV1.isDisposedInvoked); + Assert.IsTrue(this.dummyDataCollectionManagerV2.isDisposedInvoked); + } + + [TestMethod] + public void DisposeShouldDisposeResourcesIfNoDataCollectionManagersAreProvided() + { + this.dataCollectionCoordinator = new DataCollectionCoordinator(null); + + this.dataCollectionCoordinator.Dispose(); + } + } + + internal class DummyDataCollectionManager : IDataCollectionManager + { + public bool isLoadCollectorsInvoked; + public bool isSessionStartedInvoked; + public bool isSessionEndedInvoked; + public Dictionary envVariables; + public bool loadDataCollectorsThrowException; + public Collection attachments; + public bool sessionEndedThrowsException; + public bool isDisposedInvoked; + public int ThreadId; + + public void Dispose() + { + this.isDisposedInvoked = true; + } + + public Dictionary LoadDataCollectors(RunSettings settingsXml) + { + this.ThreadId = Thread.CurrentThread.ManagedThreadId; + + if (this.loadDataCollectorsThrowException) + { + throw new Exception("DataCollectionManagerException"); + } + + this.isLoadCollectorsInvoked = true; + return this.envVariables; + + } + + public void TestCaseStarted(TestCaseStartEventArgs testCaseStartEventArgs) + { + throw new NotImplementedException(); + } + + public Collection SessionEnded(bool isCancelled) + { + this.ThreadId = Thread.CurrentThread.ManagedThreadId; + + if (this.sessionEndedThrowsException) + { + throw new Exception("DataCollectionManagerException"); + } + + this.isSessionEndedInvoked = true; + return this.attachments; + } + + public bool SessionStarted() + { + this.ThreadId = Thread.CurrentThread.ManagedThreadId; + this.isSessionStartedInvoked = true; + return true; + } + + public Collection TestCaseEnded(TestCase testCase, TestOutcome testOutcome) + { + throw new NotImplementedException(); + } + } +} diff --git a/test/datacollector.x86.UnitTests/Properties/AssemblyInfo.cs b/test/datacollector.x86.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..4b70dd5208 --- /dev/null +++ b/test/datacollector.x86.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("datacollector.x86.UnitTests")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("00aa21f3-31e4-4748-ac0b-c4eadb41ca24")] diff --git a/test/datacollector.x86.UnitTests/datacollector.x86.UnitTests.xproj b/test/datacollector.x86.UnitTests/datacollector.x86.UnitTests.xproj new file mode 100644 index 0000000000..260aa86449 --- /dev/null +++ b/test/datacollector.x86.UnitTests/datacollector.x86.UnitTests.xproj @@ -0,0 +1,22 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 00aa21f3-31e4-4748-ac0b-c4eadb41ca24 + Microsoft.VisualStudio.TestPlatform.DataCollector.UnitTests + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\ + v4.5.2 + + + 2.0 + + + + + + \ No newline at end of file diff --git a/test/datacollector.x86.UnitTests/project.json b/test/datacollector.x86.UnitTests/project.json new file mode 100644 index 0000000000..f023a24637 --- /dev/null +++ b/test/datacollector.x86.UnitTests/project.json @@ -0,0 +1,35 @@ +{ + "version": "15.0.0-*", + + "buildOptions": { + "delaySign": true, + "keyFile": "../../scripts/key.snk", + "warningsAsErrors": true + }, + + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + }, + "dotnet-test-mstest": { + "version": "1.0.1-preview", + "exclude": "compile" + }, + "MSTest.TestFramework": "1.0.0-preview", + "moq.netcore": "4.4.0-beta8", + "System.Diagnostics.TraceSource": "4.0.0-rc2-24015", + "datacollector": "15.0.0-*" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dnxcore50", + "portable-net45+win8" + ] + } + }, + + "testRunner": "mstest" +} diff --git a/test/testhost.UnitTests/project.json b/test/testhost.UnitTests/project.json index 7e62f5d035..f66c69f3ad 100644 --- a/test/testhost.UnitTests/project.json +++ b/test/testhost.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview", diff --git a/test/vstest.console.UnitTests/project.json b/test/vstest.console.UnitTests/project.json index 7ba42723ec..9a5054f7ac 100644 --- a/test/vstest.console.UnitTests/project.json +++ b/test/vstest.console.UnitTests/project.json @@ -10,7 +10,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc2-3002702" + "version": "1.0.0" }, "dotnet-test-mstest": { "version": "1.0.1-preview",