From 0ac12abcf8789624554249617d014cc6504425aa Mon Sep 17 00:00:00 2001 From: Jing Xia <185141590+xj-ms@users.noreply.github.com> Date: Thu, 16 Jul 2026 17:19:56 -0700 Subject: [PATCH 1/2] Upgrade to MSTest4 --- src/Directory.Build.targets | 6 +- .../Plugins/PluginsLoaderTests.cs | 60 ++++------ .../ColumnBuilding/EmptyColumnBuilderTests.cs | 14 +-- .../ColumnBuilding/ModalColumnBuilderTests.cs | 12 +- .../ToggledColumnBuilderTests.cs | 12 +- .../CookedDataReflectorTests.cs | 4 +- .../DataSourceResolverTests.cs | 6 +- .../AssemblyExtensionDiscoveryTests.cs | 2 +- .../CompositeCookerRepositoryTests.cs | 4 +- .../CompositeDataCookerReferenceTests.cs | 22 ++-- .../DataCookerSchedulingNodeTests.cs | 8 +- .../DataExtensionDependencyTests.cs | 4 +- .../DataExtensionRepositoryTests.cs | 16 +-- .../DataExtensionRetrievalFactoryTests.cs | 14 +-- .../DataProcessorReferenceTests.cs | 26 ++--- .../DependencyDagExtensionsTests.cs | 4 +- .../Extensibility/DependencyDagTests.cs | 10 +- .../SourceDataCookerReferenceTests.cs | 24 ++-- .../Extensibility/SourceSessionTests.cs | 6 +- .../TableExtensionReferenceTests.cs | 12 +- .../Options/PluginOptionsSystemTests.cs | 6 +- .../Options/StreamPluginOptionsLoaderTests.cs | 2 +- .../Options/StreamPluginOptionsSaverTests.cs | 2 +- .../ProcessingSourceExecutorTests.cs | 4 +- .../ProcessingSourceReferenceTests.cs | 48 ++++---- .../TableBuilderTests.cs | 24 ++-- .../VersionCheckerTests.cs | 5 +- .../CollectionExtensionsTests.cs | 4 +- .../ColumnVariantsTests.cs | 6 +- .../DataSourceInfoTests.cs | 12 +- .../DirectoryDataSourceAttributeTests.cs | 4 +- ...tensionlessFileDataSourceAttributeTests.cs | 4 +- .../FileDataSourceAttributeTests.cs | 8 +- .../ProcessingSourceTests.cs | 8 +- .../ProjectionTests.cs | 108 ++++++++--------- .../TableConfigurationTests.cs | 10 +- .../TestClasses/TableDescriptorUtils.cs | 6 +- .../TypeExtensionTests.cs | 10 +- src/Microsoft.Performance.Testing/AssertEx.cs | 6 +- .../DataSourceSetTests.cs | 24 ++-- .../EngineFixture.cs | 7 +- .../PluginSetTests.cs | 6 +- .../ToolkitEngineCreateInfoTests.cs | 2 +- .../ToolkitEngineTests.cs | 110 ++++++++---------- ...formance.Toolkit.Plugins.Core.Tests.csproj | 13 ++- .../FileSystemInstalledPluginStorageTests.cs | 2 +- .../FileSystemPluginRegistryTests.cs | 26 ++--- ...mance.Toolkit.Plugins.Runtime.Tests.csproj | 15 ++- .../PluginSourcesRepositoryTests.cs | 8 +- ...rformance.Toolkit.Plugins.Cli.Tests.csproj | 12 +- 50 files changed, 369 insertions(+), 399 deletions(-) diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index baef63bf8..cde6973c8 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,9 +1,9 @@ - - - + + + diff --git a/src/Microsoft.Performance.SDK.Runtime.NetCoreApp.Tests/Plugins/PluginsLoaderTests.cs b/src/Microsoft.Performance.SDK.Runtime.NetCoreApp.Tests/Plugins/PluginsLoaderTests.cs index e9377142a..cc111e97c 100644 --- a/src/Microsoft.Performance.SDK.Runtime.NetCoreApp.Tests/Plugins/PluginsLoaderTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.NetCoreApp.Tests/Plugins/PluginsLoaderTests.cs @@ -115,7 +115,7 @@ public static void Initialize(TestContext context) // If this Assert is hit, the SDK was likely updated to break // the processing source definitions used to test this class - Assert.Fail("ProcessingSource {0} failed to compile", plugin); + Assert.Fail($"ProcessingSource {plugin} failed to compile"); } else { @@ -130,7 +130,7 @@ public static void Initialize(TestContext context) public void NullDirectoryThrows() { (var loader, _) = Setup(true); - Assert.ThrowsException(() => loader.TryLoadPlugin(null, out _)); + Assert.ThrowsExactly(() => loader.TryLoadPlugin(null, out _)); } [TestMethod] @@ -138,7 +138,7 @@ public void NullDirectoryThrows() public async Task NullDirectoryThrowsAsync() { (var loader, _) = Setup(true); - await Assert.ThrowsExceptionAsync(() => loader.TryLoadPluginAsync(null)); + await Assert.ThrowsExactlyAsync(() => loader.TryLoadPluginAsync(null)); } [TestMethod] @@ -146,7 +146,7 @@ public async Task NullDirectoryThrowsAsync() public void NullDirectoriesThrows() { (var loader, _) = Setup(true); - Assert.ThrowsException(() => loader.TryLoadPlugins(null, out _)); + Assert.ThrowsExactly(() => loader.TryLoadPlugins(null, out _)); } [TestMethod] @@ -154,7 +154,7 @@ public void NullDirectoriesThrows() public async Task NullDirectoriesThrowsAsync() { (var loader, _) = Setup(true); - await Assert.ThrowsExceptionAsync(() => loader.TryLoadPluginsAsync(null)); + await Assert.ThrowsExactlyAsync(() => loader.TryLoadPluginsAsync(null)); } [TestMethod] @@ -162,7 +162,7 @@ public async Task NullDirectoriesThrowsAsync() public void NullDirectoryInDirectoriesThrows() { (var loader, _) = Setup(true); - Assert.ThrowsException(() => loader.TryLoadPlugins(new List() { "foo", null }, out _)); + Assert.ThrowsExactly(() => loader.TryLoadPlugins(new List() { "foo", null }, out _)); } [TestMethod] @@ -170,7 +170,7 @@ public void NullDirectoryInDirectoriesThrows() public async Task NullDirectoryInDirectoriesThrowsAsync() { (var loader, _) = Setup(true); - await Assert.ThrowsExceptionAsync(() => loader.TryLoadPluginsAsync(new List() { "foo", null })); + await Assert.ThrowsExactlyAsync(() => loader.TryLoadPluginsAsync(new List() { "foo", null })); } [TestMethod] @@ -635,9 +635,7 @@ public void ConcurrentLoadTest() // Assert blocking observed first plugin Assert.AreEqual(expected0.Length, blockingConsumer.ObservedDataSources.Count, - "Blocking consumer observed {0} data sources but should have observed {1}", - blockingConsumer.ObservedDataSources.Count, - expected0.Length); + $"Blocking consumer observed {blockingConsumer.ObservedDataSources.Count} data sources but should have observed {expected0.Length}"); AssertObservedCDSs(expected0, blockingConsumer); // Allow InvalidB to be processed @@ -660,16 +658,16 @@ public async Task WhenDisposed_EverythingThrows() { sut.Dispose(); - Assert.ThrowsException(() => sut.LoadedProcessingSources); + Assert.ThrowsExactly(() => sut.LoadedProcessingSources); - Assert.ThrowsException(() => sut.Subscribe(new MockPluginsConsumer())); - await Assert.ThrowsExceptionAsync(() => sut.SubscribeAsync(new MockPluginsConsumer())); - Assert.ThrowsException(() => sut.TryLoadPlugin(Any.FilePath(), out _)); - await Assert.ThrowsExceptionAsync(() => sut.TryLoadPluginAsync(Any.FilePath())); - Assert.ThrowsException(() => sut.TryLoadPlugins(new[] { Any.FilePath(), }, out _)); - await Assert.ThrowsExceptionAsync(() => sut.TryLoadPluginsAsync(new[] { Any.FilePath(), })); - Assert.ThrowsException(() => sut.Unsubscribe(new MockPluginsConsumer())); - await Assert.ThrowsExceptionAsync(() => sut.UnsubscribeAsync(new MockPluginsConsumer())); + Assert.ThrowsExactly(() => sut.Subscribe(new MockPluginsConsumer())); + await Assert.ThrowsExactlyAsync(() => sut.SubscribeAsync(new MockPluginsConsumer())); + Assert.ThrowsExactly(() => sut.TryLoadPlugin(Any.FilePath(), out _)); + await Assert.ThrowsExactlyAsync(() => sut.TryLoadPluginAsync(Any.FilePath())); + Assert.ThrowsExactly(() => sut.TryLoadPlugins(new[] { Any.FilePath(), }, out _)); + await Assert.ThrowsExactlyAsync(() => sut.TryLoadPluginsAsync(new[] { Any.FilePath(), })); + Assert.ThrowsExactly(() => sut.Unsubscribe(new MockPluginsConsumer())); + await Assert.ThrowsExactlyAsync(() => sut.UnsubscribeAsync(new MockPluginsConsumer())); } } @@ -741,17 +739,12 @@ private static void AssertNumberProcessingSourcesLoaded(int expected, PluginsLoa { Assert.AreEqual(expected, loader.LoadedProcessingSources.Count(), - "The plugins loader reports having loaded {0} instead of {1} processing sources", - loader.LoadedProcessingSources.Count(), - expected); + $"The plugins loader reports having loaded {loader.LoadedProcessingSources.Count()} instead of {expected} processing sources"); foreach (var consumer in consumers) { Assert.AreEqual(expected, consumer.ObservedDataSources.Count, - "Consumer {0} observed {1} instead of {2} processing sources", - consumer, - consumer.ObservedDataSources.Count, - expected); + $"Consumer {consumer} observed {consumer.ObservedDataSources.Count} instead of {expected} processing sources"); } } @@ -794,22 +787,13 @@ private static void AssertCDSs(Type[] types, IEnumerable(() => + Assert.ThrowsExactly(() => { builder.WithToggle(null, Projection.Constant(1f)); }); @@ -34,7 +34,7 @@ public void WithToggle_NullProjectionThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithToggle(new ColumnVariantDescriptor(Guid.NewGuid(), new ColumnVariantProperties { Label = "Foo" }), null); }); @@ -45,7 +45,7 @@ public void WithHierarchicalToggle_NullIdentifierThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalToggle( null, @@ -59,7 +59,7 @@ public void WithHierarchicalToggle_NullProjectionThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalToggle( new ColumnVariantDescriptor(Guid.NewGuid(), new ColumnVariantProperties { Label = "Foo" }), @@ -73,7 +73,7 @@ public void WithHierarchicalToggle_NullCollectionInfoThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalToggle( new ColumnVariantDescriptor(Guid.NewGuid(), new ColumnVariantProperties { Label = "Foo" }), @@ -87,7 +87,7 @@ public void WithToggledModes_NullTextThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => { builder.WithToggledModes(null, builder => builder); }); + Assert.ThrowsExactly(() => { builder.WithToggledModes(null, builder => builder); }); } [TestMethod] @@ -103,7 +103,7 @@ public void WithModes_NullPropertiesThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => { builder.WithModes(null, builder => builder); }); + Assert.ThrowsExactly(() => { builder.WithModes(null, builder => builder); }); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ModalColumnBuilderTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ModalColumnBuilderTests.cs index 4251cd139..fa7835da0 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ModalColumnBuilderTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ModalColumnBuilderTests.cs @@ -27,7 +27,7 @@ public void WithMode_NullIdentifierThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithMode(null, Projection.Constant(1f)); }); @@ -38,7 +38,7 @@ public void WithMode_NullProjectionThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithMode(modeDescriptor, null); }); @@ -57,7 +57,7 @@ public void WithHierarchicalMode_NullIdentifierThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalMode( null, @@ -71,7 +71,7 @@ public void WithHierarchicalMode_NullProjectionThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalMode( modeDescriptor, @@ -85,7 +85,7 @@ public void WithHierarchicalMode_NullCollectionInfoThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalMode( modeDescriptor, @@ -111,7 +111,7 @@ public void WithDefaultMode_UnregisteredGuidThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithDefaultMode(Guid.NewGuid()); }); diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ToggledColumnBuilderTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ToggledColumnBuilderTests.cs index 245c0d670..7b7dc7dbd 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ToggledColumnBuilderTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/ColumnBuilding/ToggledColumnBuilderTests.cs @@ -23,7 +23,7 @@ public void WithToggle_NullIdentifierThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithToggle(null, Projection.Constant(1f)); }); @@ -34,7 +34,7 @@ public void WithToggle_NullProjectionThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithToggle(new ColumnVariantDescriptor(Guid.NewGuid(), new ColumnVariantProperties { Label = "Foo" }), null); }); @@ -45,7 +45,7 @@ public void WithHierarchicalToggle_NullIdentifierThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalToggle( null, @@ -59,7 +59,7 @@ public void WithHierarchicalToggle_NullProjectionThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalToggle( new ColumnVariantDescriptor(Guid.NewGuid(), new ColumnVariantProperties { Label = "Foo" }), @@ -73,7 +73,7 @@ public void WithHierarchicalToggle_NullCollectionInfoThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { builder.WithHierarchicalToggle( new ColumnVariantDescriptor(Guid.NewGuid(), new ColumnVariantProperties { Label = "Foo" }), @@ -87,7 +87,7 @@ public void WithToggledModes_NullTextThrows() { var builder = CreateSut(); - Assert.ThrowsException(() => { builder.WithToggledModes(null, modesBuilder => modesBuilder); }); + Assert.ThrowsExactly(() => { builder.WithToggledModes(null, modesBuilder => modesBuilder); }); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/CookedDataReflectorTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/CookedDataReflectorTests.cs index 0157e1d4e..faf763852 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/CookedDataReflectorTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/CookedDataReflectorTests.cs @@ -112,7 +112,7 @@ public void TryQueryAddFuncAsFunc() [UnitTest] public void QueryAsWrongTypeThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => testReflector.QueryOutput( new DataOutputPath(TestCookedDataReflector.DefaultCookerPath, nameof(TestCookedDataReflector.AddFunc)))); } @@ -133,7 +133,7 @@ public void TryQueryAsWrongTypeFails() [UnitTest] public void QueryNonExistentPathThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => testReflector.QueryOutput( new DataOutputPath(TestCookedDataReflector.DefaultCookerPath, "DoesNotExist"))); } diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/DataSourceResolverTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/DataSourceResolverTests.cs index a3a6947d5..b040f18bf 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/DataSourceResolverTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/DataSourceResolverTests.cs @@ -24,7 +24,7 @@ public class DataSourceResolverTests [UnitTest] public void Assign_NullDataSourcesThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => DataSourceResolver.Assign(null, Array.Empty())); } @@ -32,7 +32,7 @@ public void Assign_NullDataSourcesThrows() [UnitTest] public void Assign_NullProcessingSourcesThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => DataSourceResolver.Assign(Array.Empty(), null)); } @@ -161,7 +161,7 @@ public void AssignTests(AssignTestCase testCase) var ecds = kvp.Key; var eds = kvp.Value.ToList(); - Assert.IsTrue(actual.ContainsKey(ecds), "'{0}' is not found in the assignment.", ecds); + Assert.IsTrue(actual.ContainsKey(ecds), $"'{ecds}' is not found in the assignment."); var ads = actual[ecds].ToList(); CollectionAssert.AreEquivalent(eds, ads); diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Discovery/AssemblyExtensionDiscoveryTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Discovery/AssemblyExtensionDiscoveryTests.cs index db46e0b1d..163cfb83a 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Discovery/AssemblyExtensionDiscoveryTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Discovery/AssemblyExtensionDiscoveryTests.cs @@ -134,7 +134,7 @@ public void Setup() [UnitTest] public void ProcessAssemblies_NullDirectoryPath() { - Assert.ThrowsException(() => this.Discovery.ProcessAssemblies((string)null, out _)); + Assert.ThrowsExactly(() => this.Discovery.ProcessAssemblies((string)null, out _)); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeCookerRepositoryTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeCookerRepositoryTests.cs index 4ed6bef69..2aa626740 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeCookerRepositoryTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeCookerRepositoryTests.cs @@ -35,14 +35,14 @@ public void Cleanup() [UnitTest] public void Constructor_NullParam_Throws() { - Assert.ThrowsException(() => new ProcessingSystemCompositeCookers(null)); + Assert.ThrowsExactly(() => new ProcessingSystemCompositeCookers(null)); } [TestMethod] [UnitTest] public void Initialize_NullParam_Throws() { - Assert.ThrowsException(() => this.Sut.Initialize(null)); + Assert.ThrowsExactly(() => this.Sut.Initialize(null)); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeDataCookerReferenceTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeDataCookerReferenceTests.cs index 9847e6410..fd0780f8b 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeDataCookerReferenceTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/CompositeDataCookerReferenceTests.cs @@ -34,20 +34,20 @@ public void WhenDisposed_EverthingThrows() sut.Dispose(); - Assert.ThrowsException(() => sut.Availability); - Assert.ThrowsException(() => sut.DependencyReferences); - Assert.ThrowsException(() => sut.Description); - Assert.ThrowsException(() => sut.InitialAvailability); - Assert.ThrowsException(() => sut.Name); - Assert.ThrowsException(() => sut.Path); - Assert.ThrowsException(() => sut.RequiredDataCookers); + Assert.ThrowsExactly(() => sut.Availability); + Assert.ThrowsExactly(() => sut.DependencyReferences); + Assert.ThrowsExactly(() => sut.Description); + Assert.ThrowsExactly(() => sut.InitialAvailability); + Assert.ThrowsExactly(() => sut.Name); + Assert.ThrowsExactly(() => sut.Path); + Assert.ThrowsExactly(() => sut.RequiredDataCookers); // TODO: __SDK_DP__ // Redesign Data Processor API - // Assert.ThrowsException(() => sut.RequiredDataProcessors); + // Assert.ThrowsExactly(() => sut.RequiredDataProcessors); - Assert.ThrowsException(() => sut.CreateInstance(new FakeRetrieval())); - Assert.ThrowsException(() => sut.PerformAdditionalDataExtensionValidation(new FakeSupport(), new FakeReference())); - Assert.ThrowsException(() => sut.ProcessDependencies(new TestDataExtensionRepository())); + Assert.ThrowsExactly(() => sut.CreateInstance(new FakeRetrieval())); + Assert.ThrowsExactly(() => sut.PerformAdditionalDataExtensionValidation(new FakeSupport(), new FakeReference())); + Assert.ThrowsExactly(() => sut.ProcessDependencies(new TestDataExtensionRepository())); } finally { diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataCookerSchedulingNodeTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataCookerSchedulingNodeTests.cs index c719feb4b..e6368bae1 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataCookerSchedulingNodeTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataCookerSchedulingNodeTests.cs @@ -137,7 +137,7 @@ public void Initialize() [UnitTest] public void ConstructorThrowsWithoutDependencySupportInDataCooker() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => DataCookerSchedulingNode.CreateSchedulingNode(new DataCookerWithoutDependencies())); } @@ -245,7 +245,7 @@ public void ScheduleDataCookers_CircularDependenciesThrows() scheduler.AddNode(cookerWithCircularDependency2Node); scheduler.AddNode(cookerWithCircularDependency3Node); - Assert.ThrowsException( + Assert.ThrowsExactly( () => cookerWithCircularDependency1Node.Schedule(scheduler, null)); } @@ -1287,7 +1287,7 @@ public void AsRequiredNode_DependentNotAligned_Throws() scheduler.AddNode(node); scheduler.AddNode(asRequiredNode); - Assert.ThrowsException(() => node.Schedule(scheduler, null)); + Assert.ThrowsExactly(() => node.Schedule(scheduler, null)); } [TestMethod] @@ -1321,7 +1321,7 @@ public void AsRequiredNode_NonAsRequiredDependency_Throws() scheduler.AddNode(node2); scheduler.AddNode(asRequiredNode); - Assert.ThrowsException(() => node1.Schedule(scheduler, null)); + Assert.ThrowsExactly(() => node1.Schedule(scheduler, null)); } } } diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionDependencyTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionDependencyTests.cs index bce7a9c86..97255c001 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionDependencyTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionDependencyTests.cs @@ -20,7 +20,7 @@ public class DataExtensionDependencyTests [UnitTest] public void ConstructorThrowsForNullDependencyTarget() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new DataExtensionDependencyState((IDataExtensionDependencyTarget)null)); } @@ -28,7 +28,7 @@ public void ConstructorThrowsForNullDependencyTarget() [UnitTest] public void ConstructorThrowsForNullOther() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new DataExtensionDependencyState((DataExtensionDependencyState)null)); } diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRepositoryTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRepositoryTests.cs index bb623bf40..e11b7523e 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRepositoryTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRepositoryTests.cs @@ -33,19 +33,19 @@ public void WhenDisposed_EverythingThrows() { this.Sut.Dispose(); - Assert.ThrowsException(() => this.Sut.CompositeDataCookers); + Assert.ThrowsExactly(() => this.Sut.CompositeDataCookers); // TODO: __SDK_DP__ // Redesign Data Processor API - ////Assert.ThrowsException(() => this.Sut.DataProcessors); - Assert.ThrowsException(() => this.Sut.SourceDataCookers); - Assert.ThrowsException(() => this.Sut.TablesById); + ////Assert.ThrowsExactly(() => this.Sut.DataProcessors); + Assert.ThrowsExactly(() => this.Sut.SourceDataCookers); + Assert.ThrowsExactly(() => this.Sut.TablesById); - Assert.ThrowsException(() => this.Sut.GetCompositeDataCookerReference(new DataCookerPath())); + Assert.ThrowsExactly(() => this.Sut.GetCompositeDataCookerReference(new DataCookerPath())); // TODO: __SDK_DP__ // Redesign Data Processor API - ////Assert.ThrowsException(() => this.Sut.GetDataProcessorReference(new DataProcessorId())); - Assert.ThrowsException(() => this.Sut.GetSourceDataCookerFactory(new DataCookerPath())); - Assert.ThrowsException(() => this.Sut.GetSourceDataCookerReference(new DataCookerPath())); + ////Assert.ThrowsExactly(() => this.Sut.GetDataProcessorReference(new DataProcessorId())); + Assert.ThrowsExactly(() => this.Sut.GetSourceDataCookerFactory(new DataCookerPath())); + Assert.ThrowsExactly(() => this.Sut.GetSourceDataCookerReference(new DataCookerPath())); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRetrievalFactoryTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRetrievalFactoryTests.cs index 45ec23168..5759c44a0 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRetrievalFactoryTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataExtensionRetrievalFactoryTests.cs @@ -34,7 +34,7 @@ public void Constructor_NullRepo_Throws() var sourceCookerData = CreateSourceCookerData(); var compositeCookerData = CreateCompositeCookerData(dataExtensionRepository); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => new DataExtensionRetrievalFactory(sourceCookerData, compositeCookerData, null)); } @@ -45,7 +45,7 @@ public void Constructor_NullSourceCookerData_Throws() var dataExtensionRepository = new TestDataExtensionRepository(); var compositeCookerData = CreateCompositeCookerData(dataExtensionRepository); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => new DataExtensionRetrievalFactory(null, compositeCookerData, dataExtensionRepository)); } @@ -56,7 +56,7 @@ public void Constructor_NullCompositeCookerData_Throws() var dataExtensionRepository = new TestDataExtensionRepository(); var sourceCookerData = CreateSourceCookerData(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => new DataExtensionRetrievalFactory(sourceCookerData, null, dataExtensionRepository)); } @@ -112,7 +112,7 @@ public void CreateDataRetrievalForCompositeDataCooker_MissingCookerThrows() var dataExtensionRetrievalFactory = new DataExtensionRetrievalFactory(sourceCookerData, compositeCookerData, dataExtensionRepository); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => dataExtensionRetrievalFactory.CreateDataRetrievalForCompositeDataCooker(cookerPath)); } @@ -135,7 +135,7 @@ public void CreateDataRetrievalForCompositeDataCooker_NotAvailableCookerThrows() var dataExtensionRetrievalFactory = new DataExtensionRetrievalFactory(sourceCookerData, compositeCookerData, dataExtensionRepository); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => dataExtensionRetrievalFactory.CreateDataRetrievalForCompositeDataCooker(dataCookerReference.Path)); } @@ -199,7 +199,7 @@ public void CreateDataRetrievalForTable_MissingCookerThrows() var dataExtensionRetrievalFactory = new DataExtensionRetrievalFactory(sourceCookerData, compositeCookerData, dataExtensionRepository); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => dataExtensionRetrievalFactory.CreateDataRetrievalForTable(tableId)); } @@ -230,7 +230,7 @@ public void CreateDataRetrievalForTable_NotAvailableCookerThrows() var dataExtensionRetrievalFactory = new DataExtensionRetrievalFactory(sourceCookerData, compositeCookerData, dataExtensionRepository); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => dataExtensionRetrievalFactory.CreateDataRetrievalForTable(tableReference.TableDescriptor.Guid)); } } diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataProcessorReferenceTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataProcessorReferenceTests.cs index 1eb8ed87c..1d83cef70 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataProcessorReferenceTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DataProcessorReferenceTests.cs @@ -34,19 +34,19 @@ namespace Microsoft.Performance.SDK.Runtime.Tests.Extensibility //// sut.Dispose(); - //// Assert.ThrowsException(() => sut.Availability); - //// Assert.ThrowsException(() => sut.DependencyReferences); - //// Assert.ThrowsException(() => sut.DependencyState); - //// Assert.ThrowsException(() => sut.Description); - //// Assert.ThrowsException(() => sut.Id); - //// Assert.ThrowsException(() => sut.InitialAvailability); - //// Assert.ThrowsException(() => sut.Name); - //// Assert.ThrowsException(() => sut.RequiredDataCookers); - //// Assert.ThrowsException(() => sut.RequiredDataProcessors); - - //// Assert.ThrowsException(() => sut.GetOrCreateInstance(new FakeRetrieval())); - //// Assert.ThrowsException(() => sut.PerformAdditionalDataExtensionValidation(new FakeSupport(), new FakeReference())); - //// Assert.ThrowsException(() => sut.ProcessDependencies(new TestDataExtensionRepository())); + //// Assert.ThrowsExactly(() => sut.Availability); + //// Assert.ThrowsExactly(() => sut.DependencyReferences); + //// Assert.ThrowsExactly(() => sut.DependencyState); + //// Assert.ThrowsExactly(() => sut.Description); + //// Assert.ThrowsExactly(() => sut.Id); + //// Assert.ThrowsExactly(() => sut.InitialAvailability); + //// Assert.ThrowsExactly(() => sut.Name); + //// Assert.ThrowsExactly(() => sut.RequiredDataCookers); + //// Assert.ThrowsExactly(() => sut.RequiredDataProcessors); + + //// Assert.ThrowsExactly(() => sut.GetOrCreateInstance(new FakeRetrieval())); + //// Assert.ThrowsExactly(() => sut.PerformAdditionalDataExtensionValidation(new FakeSupport(), new FakeReference())); + //// Assert.ThrowsExactly(() => sut.ProcessDependencies(new TestDataExtensionRepository())); //// } //// finally //// { diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagExtensionsTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagExtensionsTests.cs index 1de9e96f5..ca9b0dafd 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagExtensionsTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagExtensionsTests.cs @@ -26,8 +26,8 @@ public void DependentWalk_NullParameters_Throw() var dag = DependencyDag.Create(catalog, repo); - Assert.ThrowsException(() => DependencyDagExtensions.DependentWalk(null, x => { })); - Assert.ThrowsException(() => dag.DependentWalk(null)); + Assert.ThrowsExactly(() => DependencyDagExtensions.DependentWalk(null, x => { })); + Assert.ThrowsExactly(() => dag.DependentWalk(null)); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagTests.cs index 0467e4645..de2b234b1 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/DependencyDagTests.cs @@ -24,8 +24,8 @@ public class DependencyDagTests [UnitTest] public void Create_NullParameters_Throw() { - Assert.ThrowsException(() => DependencyDag.Create(null, new TestDataExtensionRepository())); - Assert.ThrowsException(() => DependencyDag.Create(new TestProcessingSourceCatalog(), null)); + Assert.ThrowsExactly(() => DependencyDag.Create(null, new TestDataExtensionRepository())); + Assert.ThrowsExactly(() => DependencyDag.Create(new TestProcessingSourceCatalog(), null)); } [TestMethod] @@ -36,7 +36,7 @@ public void Create_UnloadedCatalog_Throws() var repo = new DataExtensionRepository(); repo.FinalizeDataExtensions(); - Assert.ThrowsException(() => DependencyDag.Create(catalog, repo)); + Assert.ThrowsExactly(() => DependencyDag.Create(catalog, repo)); } [TestMethod] @@ -543,7 +543,7 @@ public void CyclesNotAllowed() repo.TryAddReference(r0d3); repo.FinalizeDataExtensions(); - var e = Assert.ThrowsException(() => DependencyDag.Create(catalog, repo)); + var e = Assert.ThrowsExactly(() => DependencyDag.Create(catalog, repo)); var expectedCycleString = string.Format( "Cycle: {0} -> {1} -> {2} -> {0}", @@ -586,7 +586,7 @@ public void DeeperCyclesNotAllowed() repo.TryAddReference(r0d3); repo.FinalizeDataExtensions(); - var e = Assert.ThrowsException(() => DependencyDag.Create(catalog, repo)); + var e = Assert.ThrowsExactly(() => DependencyDag.Create(catalog, repo)); var expectedCycleString = string.Format( "Cycle: {0} -> {1} -> {2} -> {0}", diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceDataCookerReferenceTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceDataCookerReferenceTests.cs index 33ef6531e..8a494aa83 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceDataCookerReferenceTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceDataCookerReferenceTests.cs @@ -154,21 +154,21 @@ public void WhenDisposed_EverythingThrows() sut.Dispose(); - Assert.ThrowsException(() => sut.Availability); - Assert.ThrowsException(() => sut.DependencyReferences); - Assert.ThrowsException(() => sut.Description); - Assert.ThrowsException(() => sut.InitialAvailability); - Assert.ThrowsException(() => sut.Name); - Assert.ThrowsException(() => sut.Path); - - Assert.ThrowsException(() => sut.CreateInstance()); - Assert.ThrowsException(() => sut.PerformAdditionalDataExtensionValidation(new FakeSupport(), new FakeReference())); - Assert.ThrowsException(() => sut.ProcessDependencies(new TestDataExtensionRepository())); - Assert.ThrowsException(() => sut.RequiredDataCookers); + Assert.ThrowsExactly(() => sut.Availability); + Assert.ThrowsExactly(() => sut.DependencyReferences); + Assert.ThrowsExactly(() => sut.Description); + Assert.ThrowsExactly(() => sut.InitialAvailability); + Assert.ThrowsExactly(() => sut.Name); + Assert.ThrowsExactly(() => sut.Path); + + Assert.ThrowsExactly(() => sut.CreateInstance()); + Assert.ThrowsExactly(() => sut.PerformAdditionalDataExtensionValidation(new FakeSupport(), new FakeReference())); + Assert.ThrowsExactly(() => sut.ProcessDependencies(new TestDataExtensionRepository())); + Assert.ThrowsExactly(() => sut.RequiredDataCookers); // TODO: __SDK_DP__ // Redesign Data Processor API - // Assert.ThrowsException(() => sut.RequiredDataProcessors); + // Assert.ThrowsExactly(() => sut.RequiredDataProcessors); } finally { diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceSessionTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceSessionTests.cs index 05b71de4f..1e862a1c7 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceSessionTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/SourceSessionTests.cs @@ -78,7 +78,7 @@ private TestSourceDataCooker CreateCooker( [UnitTest] public void Constructor_NullSourceParser_Throws() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new SourceProcessingSession(null)); } @@ -88,7 +88,7 @@ public void Constructor_NullSourceParserId_Throws() { var sourceParser = new TestSourceParser(); - Assert.ThrowsException( + Assert.ThrowsExactly( () => new SourceProcessingSession(sourceParser)); } @@ -109,7 +109,7 @@ public void RegisterSourceDataCooker_NullCooker_Throws() var sourceParser = new TestSourceParser() { Id = "TestSourceParser" }; var sourceSession = new SourceProcessingSession(sourceParser); - Assert.ThrowsException( + Assert.ThrowsExactly( () => sourceSession.RegisterSourceDataCooker(null)); } diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/TableExtensionReferenceTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/TableExtensionReferenceTests.cs index 90d6db4c2..83ce774d2 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/TableExtensionReferenceTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Extensibility/TableExtensionReferenceTests.cs @@ -28,13 +28,13 @@ public void WhenDisposed_EverthingThrows() sut.Dispose(); - Assert.ThrowsException(() => sut.Availability); - Assert.ThrowsException(() => sut.BuildTableAction); - Assert.ThrowsException(() => sut.DependencyReferences); - Assert.ThrowsException(() => sut.IsDataAvailableFunc); - Assert.ThrowsException(() => sut.TableDescriptor); + Assert.ThrowsExactly(() => sut.Availability); + Assert.ThrowsExactly(() => sut.BuildTableAction); + Assert.ThrowsExactly(() => sut.DependencyReferences); + Assert.ThrowsExactly(() => sut.IsDataAvailableFunc); + Assert.ThrowsExactly(() => sut.TableDescriptor); - Assert.ThrowsException(() => sut.ProcessDependencies(new TestDataExtensionRepository())); + Assert.ThrowsExactly(() => sut.ProcessDependencies(new TestDataExtensionRepository())); } finally { diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs index 893ca8d6c..7793fca78 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs @@ -102,7 +102,7 @@ public async Task TrySaveCurrentRegistry_LoaderFails_FailsToSave() [DataRow(@"C:\Foo\:bar.json")] public void BadFilePath_ThrowsArgumentException(string filePath) { - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { PluginOptionsSystem.CreateForFile(null, (_) => new NullLogger()); }); @@ -111,7 +111,7 @@ public void BadFilePath_ThrowsArgumentException(string filePath) [TestMethod] public void LongFilePath_ThrowsPathTooLongException() { - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { PluginOptionsSystem.CreateForFile(Path.Combine(@"C:\", new string('a', 50000), "foo.json"), (_) => new NullLogger()); }); @@ -120,7 +120,7 @@ public void LongFilePath_ThrowsPathTooLongException() [TestMethod] public void UnknownNetworkPath_ThrowsDirectoryNotFoundException() { - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { PluginOptionsSystem.CreateForFile(@"\\randomServer\C$\foo.json", (_) => new NullLogger()); }); diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsLoaderTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsLoaderTests.cs index 6c0c3eaeb..f3c32cdfa 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsLoaderTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsLoaderTests.cs @@ -63,7 +63,7 @@ public async Task CloseStreamOnRead_ClosesStream() await sut.TryLoadAsync(); - Assert.ThrowsException(() => stream.Position); + Assert.ThrowsExactly(() => stream.Position); Assert.IsFalse(stream.CanRead); Assert.IsFalse(stream.CanSeek); Assert.IsFalse(stream.CanWrite); diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsSaverTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsSaverTests.cs index 728f73fcc..7d4ca0db5 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsSaverTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/StreamPluginOptionsSaverTests.cs @@ -57,7 +57,7 @@ public async Task CloseStreamOnWrite_ClosesStream() var success = await sut.TrySaveAsync(TestPluginOptionDto.PluginOptionsDto()); Assert.IsTrue(success); - Assert.ThrowsException(() => stream.Position); + Assert.ThrowsExactly(() => stream.Position); Assert.IsFalse(stream.CanRead); Assert.IsFalse(stream.CanSeek); Assert.IsFalse(stream.CanWrite); diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceExecutorTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceExecutorTests.cs index c11ed380d..310148328 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceExecutorTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceExecutorTests.cs @@ -41,7 +41,7 @@ public void Cleanup() [UnitTest] public void ExecuteWithNullExecutionContextThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.InitializeCustomDataProcessor(null)); } @@ -74,7 +74,7 @@ public void ExecuteSourceThatReturnsNullThrows() Any.ProcessorEnvironment(), ProcessorOptions.Default); - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.InitializeCustomDataProcessor(executionContext)); } diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceReferenceTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceReferenceTests.cs index 59f2013e0..e42041c90 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceReferenceTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/ProcessingSourceReferenceTests.cs @@ -25,7 +25,7 @@ public class ProcessingSourceReferenceTests [UnitTest] public void TryCreateReferenceForNullTypeThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => ProcessingSourceReference.TryCreateReference( null, out ProcessingSourceReference _)); @@ -139,29 +139,29 @@ public void WhenDisposed_EverythingThrows() sut.Dispose(); - Assert.ThrowsException(() => sut.AssemblyPath); - Assert.ThrowsException(() => sut.AvailableTables); - Assert.ThrowsException(() => sut.CommandLineOptions); - Assert.ThrowsException(() => sut.TrackedProcessors); - Assert.ThrowsException(() => sut.DataSources); - Assert.ThrowsException(() => sut.Description); - Assert.ThrowsException(() => sut.Guid); - Assert.ThrowsException(() => sut.Instance); - Assert.ThrowsException(() => sut.Name); - Assert.ThrowsException(() => sut.Type); - Assert.ThrowsException(() => sut.Version); - - Assert.ThrowsException(() => sut.AreDirectoriesSupported()); - Assert.ThrowsException(() => sut.AreExtensionlessFilesSupported()); - Assert.ThrowsException(() => sut.Clone()); - Assert.ThrowsException(() => sut.CloneT()); - Assert.ThrowsException(() => sut.CreateProcessor((IDataSourceGroup)null, null, null)); - Assert.ThrowsException(() => sut.Supports(Any.DataSource())); - Assert.ThrowsException(() => sut.TryGetCanonicalFileExtensions()); - Assert.ThrowsException(() => sut.TryGetDirectoryDescription()); - Assert.ThrowsException(() => sut.TryGetExtensionlessFileDescription()); - Assert.ThrowsException(() => sut.TryGetFileDescription(".txt")); - Assert.ThrowsException(() => sut.TryGetFileExtensions()); + Assert.ThrowsExactly(() => sut.AssemblyPath); + Assert.ThrowsExactly(() => sut.AvailableTables); + Assert.ThrowsExactly(() => sut.CommandLineOptions); + Assert.ThrowsExactly(() => sut.TrackedProcessors); + Assert.ThrowsExactly(() => sut.DataSources); + Assert.ThrowsExactly(() => sut.Description); + Assert.ThrowsExactly(() => sut.Guid); + Assert.ThrowsExactly(() => sut.Instance); + Assert.ThrowsExactly(() => sut.Name); + Assert.ThrowsExactly(() => sut.Type); + Assert.ThrowsExactly(() => sut.Version); + + Assert.ThrowsExactly(() => sut.AreDirectoriesSupported()); + Assert.ThrowsExactly(() => sut.AreExtensionlessFilesSupported()); + Assert.ThrowsExactly(() => sut.Clone()); + Assert.ThrowsExactly(() => sut.CloneT()); + Assert.ThrowsExactly(() => sut.CreateProcessor((IDataSourceGroup)null, null, null)); + Assert.ThrowsExactly(() => sut.Supports(Any.DataSource())); + Assert.ThrowsExactly(() => sut.TryGetCanonicalFileExtensions()); + Assert.ThrowsExactly(() => sut.TryGetDirectoryDescription()); + Assert.ThrowsExactly(() => sut.TryGetExtensionlessFileDescription()); + Assert.ThrowsExactly(() => sut.TryGetFileDescription(".txt")); + Assert.ThrowsExactly(() => sut.TryGetFileExtensions()); } finally { diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/TableBuilderTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/TableBuilderTests.cs index 733b9b8b3..148cba848 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/TableBuilderTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/TableBuilderTests.cs @@ -49,7 +49,7 @@ public void SetRowCountReturnsBuilder() [UnitTest] public void SetRowCountDoesNotAllowNegativeNumber() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.SetRowCount(-1)); } @@ -57,7 +57,7 @@ public void SetRowCountDoesNotAllowNegativeNumber() [UnitTest] public void AddColumnDoesNotAllowNulls() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.AddColumn(null)); } @@ -96,7 +96,7 @@ public void ReplaceColumnOldNullThrows() new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.ReplaceColumn(null, column)); } @@ -109,7 +109,7 @@ public void ReplaceColumnNewNullThrows() new UIHints { Width = 200, }, Projection.CreateUsingFuncAdaptor(i => "test")); - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.ReplaceColumn(column, null)); } @@ -194,12 +194,12 @@ public void ReplaceColumnReturnsBuilder() [UnitTest] public void AddTableCommandInvalidArgumentsThrow() { - Assert.ThrowsException(() => this.Sut.AddTableCommand(null, _ => { })); - Assert.ThrowsException(() => this.Sut.AddTableCommand(string.Empty, _ => { })); - Assert.ThrowsException(() => this.Sut.AddTableCommand("test", null)); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand(null, _ => { })); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand(string.Empty, _ => { })); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand("test", null)); - Assert.ThrowsException(() => this.Sut.AddTableCommand2("test", null, (context) => { })); - Assert.ThrowsException(() => this.Sut.AddTableCommand2("test", (context) => true, null)); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand2("test", null, (context) => { })); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand2("test", (context) => true, null)); } [TestMethod] @@ -207,7 +207,7 @@ public void AddTableCommandInvalidArgumentsThrow() public void AddTableCommandDuplicateNameThrows() { this.Sut.AddTableCommand("test", _ => { }); - Assert.ThrowsException(() => this.Sut.AddTableCommand("test", _ => { })); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand("test", _ => { })); } [TestMethod] @@ -215,7 +215,7 @@ public void AddTableCommandDuplicateNameThrows() public void AddTableCommandDuplicateNameThrowsIrrespectiveOfCase() { this.Sut.AddTableCommand("test", _ => { }); - Assert.ThrowsException(() => this.Sut.AddTableCommand("tEsT", _ => { })); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand("tEsT", _ => { })); } [TestMethod] @@ -223,7 +223,7 @@ public void AddTableCommandDuplicateNameThrowsIrrespectiveOfCase() public void AddTableCommandDuplicateNameThrowsIrrespectiveOfPadding() { this.Sut.AddTableCommand("test", _ => { }); - Assert.ThrowsException(() => this.Sut.AddTableCommand(" test\t ", _ => { })); + Assert.ThrowsExactly(() => this.Sut.AddTableCommand(" test\t ", _ => { })); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/VersionCheckerTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/VersionCheckerTests.cs index c63d2d8fb..2f57dca2d 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/VersionCheckerTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/VersionCheckerTests.cs @@ -75,10 +75,7 @@ public void VersionSupportedTests( Assert.AreEqual( expected, result, - "{0} SHOULD{1} HAVE BEEN SUPPORTED BY {2}", - candidateSemVer, - expected ? string.Empty : " NOT", - sdkSemVer); + $"{candidateSemVer} SHOULD{(expected ? string.Empty : " NOT")} HAVE BEEN SUPPORTED BY {sdkSemVer}"); } private static VersionChecker CreateSut( diff --git a/src/Microsoft.Performance.SDK.Tests/CollectionExtensionsTests.cs b/src/Microsoft.Performance.SDK.Tests/CollectionExtensionsTests.cs index 0cd05780e..8b9847d42 100644 --- a/src/Microsoft.Performance.SDK.Tests/CollectionExtensionsTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/CollectionExtensionsTests.cs @@ -16,7 +16,7 @@ public class CollectionExtensionTests [UnitTest] public void AsReadOnlyArrayThrowsForNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => CollectionExtensions.AsReadOnly((object[])null)); } @@ -40,7 +40,7 @@ public void AsReadOnlyArrayReturnsReadOnlyWrapper() [UnitTest] public void AsReadOnlyIListThrowsForNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => CollectionExtensions.AsReadOnly((IList)null)); } diff --git a/src/Microsoft.Performance.SDK.Tests/ColumnVariantsTests.cs b/src/Microsoft.Performance.SDK.Tests/ColumnVariantsTests.cs index 86d36654c..b8fb6fc4d 100644 --- a/src/Microsoft.Performance.SDK.Tests/ColumnVariantsTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/ColumnVariantsTests.cs @@ -265,7 +265,7 @@ public void TogglesWithSameGuid_ThrowsInvalidOperationException() var tableBuilder = new TableBuilder(); tableBuilder.SetRowCount(1); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { tableBuilder.AddColumnWithVariants(baseConfig, utcProj, builder => { @@ -281,7 +281,7 @@ public void AddColumnWithVariants_NullColumnThrows() { var tableBuilder = new TableBuilder().SetRowCount(1); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { tableBuilder.AddColumnWithVariants(null, (builder) => builder); }); @@ -314,7 +314,7 @@ public void ToggleAndModeWithSameGuid_ThrowsInvalidOperationException() var tableBuilder = new TableBuilder(); tableBuilder.SetRowCount(1); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { tableBuilder.AddColumnWithVariants(baseConfig, utcProj, builder => { diff --git a/src/Microsoft.Performance.SDK.Tests/DataSourceInfoTests.cs b/src/Microsoft.Performance.SDK.Tests/DataSourceInfoTests.cs index e8efeba62..c97563cc8 100644 --- a/src/Microsoft.Performance.SDK.Tests/DataSourceInfoTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/DataSourceInfoTests.cs @@ -15,24 +15,24 @@ public class DataSourceInfoTests [UnitTest] public void NegativeStartThrows() { - Assert.ThrowsException(() => new DataSourceInfo(-1, 0, DateTime.UnixEpoch)); - Assert.ThrowsException(() => new DataSourceInfo(-1, 0, DateTime.UnixEpoch)); + Assert.ThrowsExactly(() => new DataSourceInfo(-1, 0, DateTime.UnixEpoch)); + Assert.ThrowsExactly(() => new DataSourceInfo(-1, 0, DateTime.UnixEpoch)); } [TestMethod] [UnitTest] public void NegativeEndThrows() { - Assert.ThrowsException(() => new DataSourceInfo(0, -1, DateTime.UnixEpoch)); - Assert.ThrowsException(() => new DataSourceInfo(0, -1, DateTime.UnixEpoch)); + Assert.ThrowsExactly(() => new DataSourceInfo(0, -1, DateTime.UnixEpoch)); + Assert.ThrowsExactly(() => new DataSourceInfo(0, -1, DateTime.UnixEpoch)); } [TestMethod] [UnitTest] public void StopLessThanStartThrows() { - Assert.ThrowsException(() => new DataSourceInfo(1, 0, DateTime.UnixEpoch)); - Assert.ThrowsException(() => new DataSourceInfo(1, 0, DateTime.UnixEpoch)); + Assert.ThrowsExactly(() => new DataSourceInfo(1, 0, DateTime.UnixEpoch)); + Assert.ThrowsExactly(() => new DataSourceInfo(1, 0, DateTime.UnixEpoch)); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Tests/DirectoryDataSourceAttributeTests.cs b/src/Microsoft.Performance.SDK.Tests/DirectoryDataSourceAttributeTests.cs index 3dadf3573..111dceb7a 100644 --- a/src/Microsoft.Performance.SDK.Tests/DirectoryDataSourceAttributeTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/DirectoryDataSourceAttributeTests.cs @@ -15,7 +15,7 @@ public class DirectoryDataSourceAttributeTests [UnitTest] public void NullDescriptionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new DirectoryDataSourceAttribute(null)); } @@ -23,7 +23,7 @@ public void NullDescriptionThrows() [UnitTest] public void WhitespaceDescriptionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new DirectoryDataSourceAttribute(string.Empty)); } diff --git a/src/Microsoft.Performance.SDK.Tests/ExtensionlessFileDataSourceAttributeTests.cs b/src/Microsoft.Performance.SDK.Tests/ExtensionlessFileDataSourceAttributeTests.cs index df903b123..b01f43a56 100644 --- a/src/Microsoft.Performance.SDK.Tests/ExtensionlessFileDataSourceAttributeTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/ExtensionlessFileDataSourceAttributeTests.cs @@ -15,7 +15,7 @@ public class ExtensionlessFileDataSourceAttributeTests [UnitTest] public void NullDescriptionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new ExtensionlessFileDataSourceAttribute(null)); } @@ -23,7 +23,7 @@ public void NullDescriptionThrows() [UnitTest] public void WhitespaceDescriptionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new ExtensionlessFileDataSourceAttribute(string.Empty)); } diff --git a/src/Microsoft.Performance.SDK.Tests/FileDataSourceAttributeTests.cs b/src/Microsoft.Performance.SDK.Tests/FileDataSourceAttributeTests.cs index d2e10f3c8..1ae902d49 100644 --- a/src/Microsoft.Performance.SDK.Tests/FileDataSourceAttributeTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/FileDataSourceAttributeTests.cs @@ -15,7 +15,7 @@ public class FileDataSourceAttributeTests [UnitTest] public void NullExtensionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new FileDataSourceAttribute(null)); } @@ -23,7 +23,7 @@ public void NullExtensionThrows() [UnitTest] public void WhitespaceExtensionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new FileDataSourceAttribute(string.Empty)); } @@ -31,7 +31,7 @@ public void WhitespaceExtensionThrows() [UnitTest] public void NullDescriptionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new FileDataSourceAttribute("ext", null)); } @@ -39,7 +39,7 @@ public void NullDescriptionThrows() [UnitTest] public void WhitespaceDescriptionThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new FileDataSourceAttribute("ext", string.Empty)); } diff --git a/src/Microsoft.Performance.SDK.Tests/ProcessingSourceTests.cs b/src/Microsoft.Performance.SDK.Tests/ProcessingSourceTests.cs index 97b943c0f..481062f63 100644 --- a/src/Microsoft.Performance.SDK.Tests/ProcessingSourceTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/ProcessingSourceTests.cs @@ -95,7 +95,7 @@ public void WhenSubClassReturnsNullProcessorThenThrows() }; sut.SetApplicationEnvironment(applicationEnvironment); - Assert.ThrowsException( + Assert.ThrowsExactly( () => sut.CreateProcessor(dataSource, Any.ProcessorEnvironment(), ProcessorOptions.Default)); } @@ -132,7 +132,7 @@ public void ManyDataSourcesWhenSubClassReturnsNullProcessorThenThrows() sut.SetApplicationEnvironment(applicationEnvironment); - Assert.ThrowsException( + Assert.ThrowsExactly( () => sut.CreateProcessor(dataSources, Any.ProcessorEnvironment(), ProcessorOptions.Default)); } @@ -176,7 +176,7 @@ public void WhenTableDiscoveryPassedInConstructorUsesDiscovery() public void WhenTableDiscoveryProvidedIsNull_DiscoveryThrows() { var sut = new CreateTableProviderBasedStubDataSource(null); - Assert.ThrowsException(() => sut.SetApplicationEnvironment(applicationEnvironment)); + Assert.ThrowsExactly(() => sut.SetApplicationEnvironment(applicationEnvironment)); } [TestMethod] @@ -226,7 +226,7 @@ public void WhenDiscoveryProvidesDuplicateTables_DiscoveryThrows() var sut = new CreateTableProviderBasedStubDataSource(discovery); - Assert.ThrowsException(() => sut.SetApplicationEnvironment(applicationEnvironment)); + Assert.ThrowsExactly(() => sut.SetApplicationEnvironment(applicationEnvironment)); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Tests/ProjectionTests.cs b/src/Microsoft.Performance.SDK.Tests/ProjectionTests.cs index 760df5d9c..2feb10922 100644 --- a/src/Microsoft.Performance.SDK.Tests/ProjectionTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/ProjectionTests.cs @@ -17,7 +17,7 @@ public class ProjectionTests [UnitTest] public void CacheThrowsWithNullArgument() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.CacheOnFirstUse(1, null)); } @@ -25,7 +25,7 @@ public void CacheThrowsWithNullArgument() [UnitTest] public void CacheThrowsWithNegativeArgument() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.CacheOnFirstUse(-1, Projection.Identity())); } @@ -82,15 +82,15 @@ object factory(int value) [UnitTest] public void ComposeThrowsWithNullArguments() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Compose(null, i => i)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Compose( Projection.Identity(), (Func)null)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Compose( Projection.Identity(), (IProjection)null)); @@ -173,10 +173,10 @@ public void IsConstant_ReturnsFalseForNull() [UnitTest] public void CreateThrowsForNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create((Func)null)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create((Func)null)); } @@ -186,85 +186,85 @@ public void CreateRejectsNonPublicMethods() { // int, T - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyPrivateMethodIntToObject)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyPrivateMethodIntToObjectStatic)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyProtectedMethodIntToObject)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyProtectedMethodIntToObjectStatic)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyInternalMethodIntToObject)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyInternalMethodIntToObjectStatic)); // T1,T2 - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyGenericPrivateMethod)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyGenericPrivateMethodStatic)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyGenericProtectedMethod)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyGenericProtectedMethodStatic)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyGenericInternalMethod)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(MyGenericInternalMethodStatic)); // non-public nested var internalInstance = new InternalNestedType(); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(internalInstance.Method)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(InternalNestedType.MethodStatic)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(internalInstance.MethodGeneric)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(InternalNestedType.MethodGenericStatic)); var protectedInstance = new ProtectedNestedType(); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(protectedInstance.Method)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(ProtectedNestedType.MethodStatic)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(protectedInstance.MethodGeneric)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(ProtectedNestedType.MethodGenericStatic)); var privateInstance = new PrivateNestedType(); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(privateInstance.Method)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(PrivateNestedType.MethodStatic)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(privateInstance.MethodGeneric)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(PrivateNestedType.MethodGenericStatic)); // anonymous - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(i => i)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Create(x => x.ToString())); } @@ -326,7 +326,7 @@ public void IdentityCreatesProjectionThatReturnsArgument() [UnitTest] public void IndexThrowsOnNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Index((IReadOnlyList)null)); } @@ -374,7 +374,7 @@ public void IndexCreatesIndexIntoReadOnlyList() [UnitTest] public void PrepopulatedCacheThrowsWithNullArgument() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.PrepopulatedCache(1, null)); } @@ -382,7 +382,7 @@ public void PrepopulatedCacheThrowsWithNullArgument() [UnitTest] public void PrepopulatedCacheThrowsWithNegativeArgument() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.PrepopulatedCache(-1, Projection.Identity())); } @@ -448,12 +448,12 @@ private static string Project_1_Projector( [UnitTest] public void Project_1_ThrowsForNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( null, Project_1_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), null)); @@ -463,7 +463,7 @@ public void Project_1_ThrowsForNull() [UnitTest] public void Project_1_ThrowsIfNonStaticFuncGiven() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), x => x.ToString())); @@ -495,19 +495,19 @@ private static string Project_2_Projector( [UnitTest] public void Project_2_ThrowsForNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( null, Projection.Constant(Guid.NewGuid()), Project_2_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), null, Project_2_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), @@ -518,7 +518,7 @@ public void Project_2_ThrowsForNull() [UnitTest] public void Project_2_ThrowsIfNonStaticFuncGiven() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), @@ -554,28 +554,28 @@ private static string Project_3_Projector( [UnitTest] public void Project_3_ThrowsForNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( null, Projection.Constant(Guid.NewGuid()), Projection.Constant(TimeSpan.Zero), Project_3_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), null, Projection.Constant(TimeSpan.Zero), Project_3_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), null, Project_3_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), @@ -587,7 +587,7 @@ public void Project_3_ThrowsForNull() [UnitTest] public void Project_3_ThrowsIfNonStaticFuncGiven() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), @@ -627,7 +627,7 @@ private static string Project_4_Projector( [UnitTest] public void Project_4_ThrowsForNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( null, Projection.Constant(Guid.NewGuid()), @@ -635,7 +635,7 @@ public void Project_4_ThrowsForNull() Projection.Constant(DateTimeOffset.MaxValue), Project_4_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), null, @@ -643,7 +643,7 @@ public void Project_4_ThrowsForNull() Projection.Constant(DateTimeOffset.MaxValue), Project_4_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), @@ -651,7 +651,7 @@ public void Project_4_ThrowsForNull() Projection.Constant(DateTimeOffset.MaxValue), Project_4_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), @@ -659,7 +659,7 @@ public void Project_4_ThrowsForNull() null, Project_4_Projector)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), @@ -672,7 +672,7 @@ public void Project_4_ThrowsForNull() [UnitTest] public void Project_4_ThrowsIfNonStaticFuncGiven() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Projection.Project( Projection.Constant(DateTime.UtcNow), Projection.Constant(Guid.NewGuid()), diff --git a/src/Microsoft.Performance.SDK.Tests/TableConfigurationTests.cs b/src/Microsoft.Performance.SDK.Tests/TableConfigurationTests.cs index 109526655..eee165823 100644 --- a/src/Microsoft.Performance.SDK.Tests/TableConfigurationTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/TableConfigurationTests.cs @@ -80,7 +80,7 @@ public void AddingColumnCollectionMissingGraphColumnIsOkay() [UnitTest] public void AddingColumnCollectionRightLeftOfLeftThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.Columns = new[] { TableConfiguration.RightFreezeColumn, @@ -92,7 +92,7 @@ public void AddingColumnCollectionRightLeftOfLeftThrows() [UnitTest] public void AddingColumnCollectionGraphLeftOfPivotThrows() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.Columns = new[] { TableConfiguration.GraphColumn, @@ -112,7 +112,7 @@ public void AddingColumnCollectionMetadataColumnSpecifiedMultipleTimesThrows() c, }; - Assert.ThrowsException( + Assert.ThrowsExactly( () => this.Sut.Columns = testCase); } } @@ -124,7 +124,7 @@ public void AddColumnRole_MetadataColumnThrows() foreach (var c in TableConfiguration.AllMetadataColumns) { var r = ColumnRole.Duration; - Assert.ThrowsException(() => this.Sut.AddColumnRole(r, c.Metadata.Guid)); + Assert.ThrowsExactly(() => this.Sut.AddColumnRole(r, c.Metadata.Guid)); } } @@ -172,7 +172,7 @@ public void AddColumnRole_DifferentRoleSameColumnThrows() this.Sut.AddColumnRole(r1, c.Metadata.Guid); - Assert.ThrowsException(() => this.Sut.AddColumnRole(r2, c.Metadata.Guid)); + Assert.ThrowsExactly(() => this.Sut.AddColumnRole(r2, c.Metadata.Guid)); } [TestMethod] diff --git a/src/Microsoft.Performance.SDK.Tests/TestClasses/TableDescriptorUtils.cs b/src/Microsoft.Performance.SDK.Tests/TestClasses/TableDescriptorUtils.cs index 177dc5f63..6250f5fac 100644 --- a/src/Microsoft.Performance.SDK.Tests/TestClasses/TableDescriptorUtils.cs +++ b/src/Microsoft.Performance.SDK.Tests/TestClasses/TableDescriptorUtils.cs @@ -39,13 +39,11 @@ internal static void CreateTableDescriptors( serializer, out TableDescriptor expected, out Action buildTableAction), - "Unable to create table descriptor for type `{0}`", - types[i]); + $"Unable to create table descriptor for type `{types[i]}`"); Assert.IsNotNull( expected, - "TableDescriptorFactory.TryCreate for type `{0}` returned true but yielded null.", - types[i]); + $"TableDescriptorFactory.TryCreate for type `{types[i]}` returned true but yielded null."); descriptors.Add(expected); buildActions.Add(buildTableAction); diff --git a/src/Microsoft.Performance.SDK.Tests/TypeExtensionTests.cs b/src/Microsoft.Performance.SDK.Tests/TypeExtensionTests.cs index 33891e09b..f17aebedd 100644 --- a/src/Microsoft.Performance.SDK.Tests/TypeExtensionTests.cs +++ b/src/Microsoft.Performance.SDK.Tests/TypeExtensionTests.cs @@ -28,7 +28,7 @@ public void IsStaticReturnsFalseForNonStaticTypes() [UnitTest] public void IsStaticThrowsOnNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => TypeExtensions.IsStatic(null)); } @@ -64,7 +64,7 @@ public void IsConcreteReturnsTrueForATypeThatCanBeConstructed() [UnitTest] public void IsConcreteThrowsOnNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => TypeExtensions.IsConcrete(null)); } @@ -79,9 +79,9 @@ public void IsReturnsTrueWhenTypesAreTheSame() [UnitTest] public void IsThrowsOnNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => TypeExtensions.Is(null, typeof(ConcreteType))); - Assert.ThrowsException( + Assert.ThrowsExactly( () => TypeExtensions.Is(typeof(ConcreteType), null)); } @@ -124,7 +124,7 @@ public void IsGenericReturnsTrueWhenTypesAreTheSame() [UnitTest] public void IsGenericThrowsOnNull() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => TypeExtensions.Is(null)); } diff --git a/src/Microsoft.Performance.Testing/AssertEx.cs b/src/Microsoft.Performance.Testing/AssertEx.cs index 158f15a0c..dd609d29b 100644 --- a/src/Microsoft.Performance.Testing/AssertEx.cs +++ b/src/Microsoft.Performance.Testing/AssertEx.cs @@ -17,9 +17,7 @@ public static void AreEqual( var areEqual = comparer.Equals(expected, actual); Assert.IsTrue( areEqual, - "AssertEx.AreEqual failed. Expected:<{0}>. Actual:<{1}>.", - expected, - actual); + $"AssertEx.AreEqual failed. Expected:<{expected}>. Actual:<{actual}>."); } public static void IsInstanceOfType(object obj) @@ -37,7 +35,7 @@ public static void IsInstanceOfType( string message, params object[] paramters) { - Assert.IsInstanceOfType(obj, typeof(T), message, paramters); + Assert.IsInstanceOfType(obj, typeof(T), string.Format(message, paramters)); } } } diff --git a/src/Microsoft.Performance.Toolkit.Engine.Tests/DataSourceSetTests.cs b/src/Microsoft.Performance.Toolkit.Engine.Tests/DataSourceSetTests.cs index d681830d2..dcadd46ff 100644 --- a/src/Microsoft.Performance.Toolkit.Engine.Tests/DataSourceSetTests.cs +++ b/src/Microsoft.Performance.Toolkit.Engine.Tests/DataSourceSetTests.cs @@ -38,7 +38,7 @@ public override void OnCleanup() [IntegrationTest] public void AddDataSource_NullFile_Throws() { - Assert.ThrowsException(() => this.Sut.AddDataSource(null, typeof(Source123DataSource))); + Assert.ThrowsExactly(() => this.Sut.AddDataSource(null, typeof(Source123DataSource))); } [TestMethod] @@ -46,7 +46,7 @@ public void AddDataSource_NullFile_Throws() public void AddDataSource_NullType_Throws() { var file = CreateTestFile(".txt"); - Assert.ThrowsException(() => this.Sut.AddDataSource(file, null)); + Assert.ThrowsExactly(() => this.Sut.AddDataSource(file, null)); } [TestMethod] @@ -60,7 +60,7 @@ public void AddDataSource_NoInstancesOfDataSourceLoaded_Throws() Assert.IsTrue(this.Sut.Plugins.ProcessingSourceReferences.Any(x => x.Instance is Source123DataSource)); var file = CreateTestFile(Source123DataSource.Extension); - var e = Assert.ThrowsException(() => this.Sut.AddDataSource(file, typeof(ToolkitEngineTests))); + var e = Assert.ThrowsExactly(() => this.Sut.AddDataSource(file, typeof(ToolkitEngineTests))); Assert.AreEqual(typeof(ToolkitEngineTests).FullName, e.RequestedProcessingSource); } @@ -71,7 +71,7 @@ public void AddDataSource_DataSourceDoesNotSupportFile_Throws() Assert.IsTrue(this.Sut.Plugins.ProcessingSourceReferences.Any(x => x.Instance is Source123DataSource)); var file = CreateTestFile(".380298502"); - var e = Assert.ThrowsException(() => this.Sut.AddDataSource(file, typeof(Source123DataSource))); + var e = Assert.ThrowsExactly(() => this.Sut.AddDataSource(file, typeof(Source123DataSource))); Assert.AreEqual(file.Uri.ToString(), e.DataSource); Assert.AreEqual(typeof(Source123DataSource).FullName, e.RequestedProcessingSource); } @@ -117,7 +117,7 @@ public void AddDataSource_FileSupportedByAtLeastOneDataSourceManyTimes_AddedSepa [IntegrationTest] public void AddDataSourceOnly_Null_Throws() { - Assert.ThrowsException(() => this.Sut.AddDataSource(null)); + Assert.ThrowsExactly(() => this.Sut.AddDataSource(null)); } [TestMethod] @@ -132,7 +132,7 @@ public void AddDataSourceOnly_NoCookersOrDataSourcesSupport_Throws() { var file = CreateTestFile(".380298502"); - var e = Assert.ThrowsException(() => this.Sut.AddDataSource(file)); + var e = Assert.ThrowsExactly(() => this.Sut.AddDataSource(file)); Assert.AreEqual(file.Uri.ToString(), e.DataSource); Assert.IsNull(e.RequestedProcessingSource); } @@ -287,7 +287,7 @@ public void TryAddDataSource_FileSupportedByAtLeastOneDataSourceManyTimes_AddedS [IntegrationTest] public void AddDataSources_NullFiles_Throws() { - Assert.ThrowsException(() => this.Sut.AddDataSources(null, typeof(Source123DataSource))); + Assert.ThrowsExactly(() => this.Sut.AddDataSources(null, typeof(Source123DataSource))); } @@ -295,14 +295,14 @@ public void AddDataSources_NullFiles_Throws() [IntegrationTest] public void AddDataSources_EmptyFiles_Throws() { - Assert.ThrowsException(() => this.Sut.AddDataSources(new IDataSource[0], typeof(Source123DataSource))); + Assert.ThrowsExactly(() => this.Sut.AddDataSources(new IDataSource[0], typeof(Source123DataSource))); } [TestMethod] [IntegrationTest] public void AddDataSources_ContainsNullFiles_Throws() { - Assert.ThrowsException(() => this.Sut.AddDataSources(new[] { (IDataSource)null, }, typeof(Source123DataSource))); + Assert.ThrowsExactly(() => this.Sut.AddDataSources(new[] { (IDataSource)null, }, typeof(Source123DataSource))); } [TestMethod] @@ -310,7 +310,7 @@ public void AddDataSources_ContainsNullFiles_Throws() public void AddDataSources_NullType_Throws() { var file = CreateTestFile(".txt"); - Assert.ThrowsException(() => this.Sut.AddDataSources(new[] { file, }, null)); + Assert.ThrowsExactly(() => this.Sut.AddDataSources(new[] { file, }, null)); } [TestMethod] @@ -320,7 +320,7 @@ public void AddDataSources_NoInstancesOfDataSourceLoaded_Throws() Assert.IsTrue(this.Sut.Plugins.ProcessingSourceReferences.Any(x => x.Instance is Source123DataSource)); var file = CreateTestFile(Source123DataSource.Extension); - var e = Assert.ThrowsException(() => this.Sut.AddDataSources(new[] { file, }, typeof(ToolkitEngineTests))); + var e = Assert.ThrowsExactly(() => this.Sut.AddDataSources(new[] { file, }, typeof(ToolkitEngineTests))); Assert.AreEqual(typeof(ToolkitEngineTests).FullName, e.RequestedProcessingSource); } @@ -332,7 +332,7 @@ public void AddDataSources_DataSourceDoesNotSupportFile_Throws() var file1 = CreateTestFile(Source123DataSource.Extension); var file2 = CreateTestFile(Source123DataSource.Extension); - var e = Assert.ThrowsException(() => this.Sut.AddDataSources(new[] { file1, file2, }, typeof(Source4DataSource))); + var e = Assert.ThrowsExactly(() => this.Sut.AddDataSources(new[] { file1, file2, }, typeof(Source4DataSource))); Assert.AreEqual(file1.Uri.ToString(), e.DataSource); Assert.AreEqual(typeof(Source4DataSource).FullName, e.RequestedProcessingSource); diff --git a/src/Microsoft.Performance.Toolkit.Engine.Tests/EngineFixture.cs b/src/Microsoft.Performance.Toolkit.Engine.Tests/EngineFixture.cs index 3ef0929cb..22ee3bcda 100644 --- a/src/Microsoft.Performance.Toolkit.Engine.Tests/EngineFixture.cs +++ b/src/Microsoft.Performance.Toolkit.Engine.Tests/EngineFixture.cs @@ -36,7 +36,7 @@ public void Initialize() } catch (Exception e) { - Assert.Fail("Initialize: Unable to create scratch directory `{0}`: {1}", this.Scratch.FullName, e); + Assert.Fail($"Initialize: Unable to create scratch directory `{this.Scratch.FullName}`: {e}"); } this.OnInitialize(); @@ -57,10 +57,7 @@ public void Cleanup() } catch (Exception e) { - Assert.Fail( - "Cleanup: Unable to delete scratch directory `{0}`: {1}", - this.Scratch.FullName, - e); + Assert.Fail($"Cleanup: Unable to delete scratch directory `{this.Scratch.FullName}`: {e}"); } } else diff --git a/src/Microsoft.Performance.Toolkit.Engine.Tests/PluginSetTests.cs b/src/Microsoft.Performance.Toolkit.Engine.Tests/PluginSetTests.cs index 5c7c34230..8b520ed18 100644 --- a/src/Microsoft.Performance.Toolkit.Engine.Tests/PluginSetTests.cs +++ b/src/Microsoft.Performance.Toolkit.Engine.Tests/PluginSetTests.cs @@ -43,7 +43,7 @@ public void ExtensionDirectory_PathIsAFile_Throws() var file = Path.Combine(this.Scratch.FullName, "test.txt"); File.WriteAllText(file, "test"); - var e = Assert.ThrowsException(() => PluginSet.Load(file)); + var e = Assert.ThrowsExactly(() => PluginSet.Load(file)); Assert.AreEqual(file, e.Path); } @@ -53,7 +53,7 @@ public void ExtensionDirectory_PathDoesNotExist_Throws() { var doesNotExist = Path.Combine(this.Scratch.FullName, "doesNotExist"); - var e = Assert.ThrowsException(() => PluginSet.Load(doesNotExist)); + var e = Assert.ThrowsExactly(() => PluginSet.Load(doesNotExist)); Assert.AreEqual(doesNotExist, e.Path); } @@ -100,7 +100,7 @@ public void ExtensionDirectories_AnInvalidPath_Throws() var dir1 = this.Scratch.CreateSubdirectory("Dir1"); var dirDoesNotExist = Path.Combine(this.Scratch.FullName, "doesNotExist"); - var e = Assert.ThrowsException(() => PluginSet.Load(new[] { dir1.FullName, dirDoesNotExist })); + var e = Assert.ThrowsExactly(() => PluginSet.Load(new[] { dir1.FullName, dirDoesNotExist })); Assert.AreEqual(dirDoesNotExist, e.Path); } diff --git a/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineCreateInfoTests.cs b/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineCreateInfoTests.cs index 04ba800a7..ddf3d32a0 100644 --- a/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineCreateInfoTests.cs +++ b/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineCreateInfoTests.cs @@ -127,7 +127,7 @@ public void NullOptionsResolver_Failure() using var dataSourceSet = DataSourceSet.Create(); var sut = new EngineCreateInfo(dataSourceSet.AsReadOnly()); IProcessingOptionsResolver resolver = null; - Assert.ThrowsException(() => sut.WithProcessorOptions(resolver)); + Assert.ThrowsExactly(() => sut.WithProcessorOptions(resolver)); } } } diff --git a/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineTests.cs b/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineTests.cs index e097e867b..40c2dfb11 100644 --- a/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineTests.cs +++ b/src/Microsoft.Performance.Toolkit.Engine.Tests/ToolkitEngineTests.cs @@ -50,20 +50,20 @@ public override void OnCleanup() [UnitTest] public void Create_NullParameters_Throw() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => Engine.Create((EngineCreateInfo)null)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Engine.Create((IDataSource)null)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Engine.Create((IDataSource)null, typeof(Source123Processor))); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Engine.Create(Any.DataSource(), null)); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Engine.Create((IEnumerable)null, typeof(Source123Processor))); - Assert.ThrowsException( + Assert.ThrowsExactly( () => Engine.Create(new[] { Any.DataSource(), }, null)); } @@ -87,7 +87,7 @@ public void Create_DataSourcesCloned() var info = new EngineCreateInfo(dataSources.AsReadOnly()); using var sut = Engine.Create(info); - Assert.AreNotSame(dataSources, sut.DataSourcesToProcess); + Assert.AreNotSame(dataSources, sut.DataSourcesToProcess); Assert.AreEqual(1, sut.DataSourcesToProcess.FreeDataSourcesToProcess.Count()); Assert.AreEqual(file, sut.DataSourcesToProcess.FreeDataSourcesToProcess.Single()); } @@ -236,7 +236,7 @@ public void EnableCooker_NotKnown_Throws() var cooker = DataCookerPath.ForComposite("not-there-id"); - var e = Assert.ThrowsException(() => sut.EnableCooker(cooker)); + var e = Assert.ThrowsExactly(() => sut.EnableCooker(cooker)); Assert.AreEqual(cooker, e.DataCookerPath); } @@ -248,7 +248,7 @@ public void EnableCooker_AlreadyProcessed_Throws() sut.Process(); - Assert.ThrowsException(() => sut.EnableCooker(this.DefaultSet.Plugins.AllCookers.First())); + Assert.ThrowsExactly(() => sut.EnableCooker(this.DefaultSet.Plugins.AllCookers.First())); } [TestMethod] @@ -260,7 +260,7 @@ public void EnableCooker_NoData_Throws() using var sut = Engine.Create(createInfo); - Assert.ThrowsException(() => sut.EnableCooker(Source4DataCooker.DataCookerPath)); + Assert.ThrowsExactly(() => sut.EnableCooker(Source4DataCooker.DataCookerPath)); } #endregion Enable Cooker @@ -369,7 +369,7 @@ public void EnableTable_NotKnown_Throws() var table = new TableDescriptor(Guid.NewGuid(), "Unknown Table", "Unknown Table"); - var e = Assert.ThrowsException(() => sut.EnableTable(table)); + var e = Assert.ThrowsExactly(() => sut.EnableTable(table)); Assert.AreEqual(table, e.Descriptor); } @@ -381,7 +381,7 @@ public void EnableTable_AlreadyProcessed_Throws() sut.Process(); - Assert.ThrowsException(() => sut.EnableTable(sut.AvailableTables.First())); + Assert.ThrowsExactly(() => sut.EnableTable(sut.AvailableTables.First())); } #endregion EnableTable @@ -652,7 +652,7 @@ public void BuildTable_MultiRowFromCookerTable( foreach (var throwingTable in testCase.ThrowingTables) { - Assert.ThrowsException(() => result.BuildTable(sut.AvailableTables.Single(x => x.Guid == Guid.Parse(throwingTable)))); + Assert.ThrowsExactly(() => result.BuildTable(sut.AvailableTables.Single(x => x.Guid == Guid.Parse(throwingTable)))); } } @@ -753,7 +753,7 @@ public void Process_AlreadyProcessed_Throws() sut.Process(); - Assert.ThrowsException(() => sut.Process()); + Assert.ThrowsExactly(() => sut.Process()); } [TestMethod] @@ -789,13 +789,13 @@ public void Process_WhenComplete_DataWasProcessed( foreach (var cooker in testCase.SourceCookersToEnable ?? Array.Empty()) { var cookerPath = DataCookerPath.ForSource(cooker.SourceParserId, cooker.DataCookerId); - Assert.IsTrue(sut.TryEnableCooker(cookerPath), "Unable to enable cooker '{0}'", cookerPath); + Assert.IsTrue(sut.TryEnableCooker(cookerPath), $"Unable to enable cooker '{cookerPath}'"); } foreach (var cooker in testCase.CompositeCookersToEnable ?? Array.Empty()) { var cookerPath = DataCookerPath.ForComposite(cooker.DataCookerId); - Assert.IsTrue(sut.TryEnableCooker(cookerPath), "Unable to enable cooker '{0}'", cookerPath); + Assert.IsTrue(sut.TryEnableCooker(cookerPath), $"Unable to enable cooker '{cookerPath}'"); } var results = sut.Process(); @@ -808,16 +808,14 @@ void assertOutput( var enumerableData = data as IEnumerable; Assert.IsNotNull( enumerableData, - "Test output data must implement IEnumerable<> (type wasn't enumerable): '{0}'", - data.GetType()); + $"Test output data must implement IEnumerable<> (type wasn't enumerable): '{data.GetType()}'"); var enumerableType = enumerableData.GetType(); var eInterface = enumerableType.GetInterface(typeof(IEnumerable<>).Name); Assert.IsNotNull( eInterface, - "Test output data must implement IEnumerable<> (interface wasn't found): {0}", - string.Join(", ", data.GetType().GetInterfaces().Select(x => x.FullName))); + $"Test output data must implement IEnumerable<> (interface wasn't found): {string.Join(", ", data.GetType().GetInterfaces().Select(x => x.FullName))}"); var collectionType = eInterface.GetGenericArguments()[0]; - Assert.IsNotNull(collectionType, "Unable to retrieve collection type for {0}", data.GetType()); + Assert.IsNotNull(collectionType, $"Unable to retrieve collection type for {data.GetType()}"); var enumeratedData = new List(); foreach (var o in enumerableData) @@ -828,8 +826,7 @@ void assertOutput( Assert.AreEqual( expectedDataPoints.Length, enumeratedData.Count, - "The processor did not process the correct amount of data: {0}", - dataOutputPath); + $"The processor did not process the correct amount of data: {dataOutputPath}"); var properties = collectionType.GetProperties() .ToDictionary(x => x.Name, x => x, StringComparer.InvariantCultureIgnoreCase); @@ -859,19 +856,16 @@ void assertOutput( Assert.IsTrue( results.TryQueryOutput(dataOutputPath, out object data), - "Output for {0} not found.", - dataOutputPathRaw); - Assert.IsNotNull(data, "output for {0} was null ???", dataOutputPathRaw); + $"Output for {dataOutputPathRaw} not found."); + Assert.IsNotNull(data, $"output for {dataOutputPathRaw} was null ???"); assertOutput(expectedDataPoints, data, dataOutputPath); Assert.IsTrue( results.TryGetCookedData(dataOutputPath.CookerPath, out var co), - "Unable to retrieve CookerOutput: {0}", - dataOutputPath.CookerPath); + $"Unable to retrieve CookerOutput: {dataOutputPath.CookerPath}"); Assert.IsTrue( co.TryQueryOutput(dataOutputPath.OutputId, out data), - "Output on CookedData {0} not found.", - dataOutputPathRaw); + $"Output on CookedData {dataOutputPathRaw} not found."); assertOutput(expectedDataPoints, data, dataOutputPath); } @@ -891,16 +885,13 @@ void assertOutput( Assert.IsFalse( results.TryQueryOutput(dataOutputPath, out var _), - "Output should not have been available: {0}", - dataOutputPathRaw); + $"Output should not have been available: {dataOutputPathRaw}"); Assert.IsTrue( results.TryGetCookedData(dataOutputPath.CookerPath, out var co), - "Source Output should have been available: {0}", - dataOutputPathRaw); + $"Source Output should have been available: {dataOutputPathRaw}"); Assert.IsFalse( co.TryQueryOutput(dataOutputPath.OutputId, out var _), - "Output should not have been available: {0}", - dataOutputPathRaw); + $"Output should not have been available: {dataOutputPathRaw}"); } foreach (var kvp in throwingCompositePaths) @@ -910,12 +901,10 @@ void assertOutput( Assert.IsFalse( results.TryQueryOutput(dataOutputPath, out var _), - "Output should not have been available: {0}", - dataOutputPathRaw); + $"Output should not have been available: {dataOutputPathRaw}"); Assert.IsFalse( results.TryGetCookedData(dataOutputPath.CookerPath, out var _), - "Composite Output should not have been available: {0}", - dataOutputPathRaw); + $"Composite Output should not have been available: {dataOutputPathRaw}"); } } @@ -965,13 +954,13 @@ public void Process_Isolated_WhenComplete_DataWasProcessed( foreach (var cooker in testCase.SourceCookersToEnable ?? Array.Empty()) { var cookerPath = DataCookerPath.ForSource(cooker.SourceParserId, cooker.DataCookerId); - Assert.IsTrue(runtime.TryEnableCooker(cookerPath), "Unable to enable cooker '{0}'", cookerPath); + Assert.IsTrue(runtime.TryEnableCooker(cookerPath), $"Unable to enable cooker '{cookerPath}'"); } foreach (var cooker in testCase.CompositeCookersToEnable ?? Array.Empty()) { var cookerPath = DataCookerPath.ForComposite(cooker.DataCookerId); - Assert.IsTrue(runtime.TryEnableCooker(cookerPath), "Unable to enable cooker '{0}'", cookerPath); + Assert.IsTrue(runtime.TryEnableCooker(cookerPath), $"Unable to enable cooker '{cookerPath}'"); } var results = runtime.Process(); @@ -983,22 +972,20 @@ public void Process_Isolated_WhenComplete_DataWasProcessed( DataOutputPath dataOutputPath = Parse(dataOutputPathRaw); Assert.IsTrue( - results.TryQueryOutput(dataOutputPath, out object data), "Output for {0} not found.", dataOutputPathRaw); - Assert.IsNotNull(data, "output for {0} was null ???", dataOutputPathRaw); + results.TryQueryOutput(dataOutputPath, out object data), $"Output for {dataOutputPathRaw} not found."); + Assert.IsNotNull(data, $"output for {dataOutputPathRaw} was null ???"); var enumerableData = data as IEnumerable; Assert.IsNotNull( enumerableData, - "Test output data must implement IEnumerable<> (type wasn't enumerable): '{0}'", - data.GetType()); + $"Test output data must implement IEnumerable<> (type wasn't enumerable): '{data.GetType()}'"); var enumerableType = enumerableData.GetType(); var eInterface = enumerableType.GetInterface(typeof(IEnumerable<>).Name); Assert.IsNotNull( eInterface, - "Test output data must implement IEnumerable<> (interface wasn't found): {0}", - string.Join(", ", data.GetType().GetInterfaces().Select(x => x.FullName))); + $"Test output data must implement IEnumerable<> (interface wasn't found): {string.Join(", ", data.GetType().GetInterfaces().Select(x => x.FullName))}"); var collectionType = eInterface.GetGenericArguments()[0]; - Assert.IsNotNull(collectionType, "Unable to retrieve collection type for {0}", data.GetType()); + Assert.IsNotNull(collectionType, $"Unable to retrieve collection type for {data.GetType()}"); var enumeratedData = new List(); foreach (var o in enumerableData) @@ -1009,8 +996,7 @@ public void Process_Isolated_WhenComplete_DataWasProcessed( Assert.AreEqual( expectedDataPoints.Length, enumeratedData.Count, - "The processor did not process the correct amount of data: {0}", - dataOutputPath); + $"The processor did not process the correct amount of data: {dataOutputPath}"); var properties = collectionType.GetProperties() .ToDictionary(x => x.Name, x => x, StringComparer.InvariantCultureIgnoreCase); @@ -1053,17 +1039,17 @@ public void WhenDisposed_EverythingThrows() sut.Dispose(); - Assert.ThrowsException(() => sut.AvailableTables); - Assert.ThrowsException(() => sut.CreateInfo); - Assert.ThrowsException(() => sut.DataSourcesToProcess); - Assert.ThrowsException(() => sut.EnabledCookers); - Assert.ThrowsException(() => sut.EnabledTables); - Assert.ThrowsException(() => sut.IsProcessed); - Assert.ThrowsException(() => sut.Plugins); - - Assert.ThrowsException(() => sut.EnableCooker(Any.DataCookerPath())); - Assert.ThrowsException(() => sut.Process()); - Assert.ThrowsException(() => sut.TryEnableCooker(Any.DataCookerPath())); + Assert.ThrowsExactly(() => sut.AvailableTables); + Assert.ThrowsExactly(() => sut.CreateInfo); + Assert.ThrowsExactly(() => sut.DataSourcesToProcess); + Assert.ThrowsExactly(() => sut.EnabledCookers); + Assert.ThrowsExactly(() => sut.EnabledTables); + Assert.ThrowsExactly(() => sut.IsProcessed); + Assert.ThrowsExactly(() => sut.Plugins); + + Assert.ThrowsExactly(() => sut.EnableCooker(Any.DataCookerPath())); + Assert.ThrowsExactly(() => sut.Process()); + Assert.ThrowsExactly(() => sut.TryEnableCooker(Any.DataCookerPath())); } [TestMethod] diff --git a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/Microsoft.Performance.Toolkit.Plugins.Core.Tests.csproj b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/Microsoft.Performance.Toolkit.Plugins.Core.Tests.csproj index 4f64c570a..532c06948 100644 --- a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/Microsoft.Performance.Toolkit.Plugins.Core.Tests.csproj +++ b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/Microsoft.Performance.Toolkit.Plugins.Core.Tests.csproj @@ -10,11 +10,14 @@ - - - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemInstalledPluginStorageTests.cs b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemInstalledPluginStorageTests.cs index 1f74ea4ab..5d6ab53a2 100644 --- a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemInstalledPluginStorageTests.cs +++ b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemInstalledPluginStorageTests.cs @@ -301,7 +301,7 @@ public async Task AddAsync_ExceptionThrownInExtractionLoop_ExceptionHandledAndEr fakeLoggerFactory); // Act - PluginPackageExtractionException e = await Assert.ThrowsExceptionAsync( + PluginPackageExtractionException e = await Assert.ThrowsExactlyAsync( async () => await sut.AddAsync(fakePluginPackage.Object, CancellationToken.None, null)); // Assert diff --git a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemPluginRegistryTests.cs b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemPluginRegistryTests.cs index 4e541a130..ca04c597b 100644 --- a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemPluginRegistryTests.cs +++ b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/FileSystemPluginRegistryTests.cs @@ -66,7 +66,7 @@ public async Task GetAllAsync_MissingData_ThrowsRepositoryCorruptedException() var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.GetAllAsync(CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.GetAllAsync(CancellationToken.None)); } [TestMethod] @@ -95,7 +95,7 @@ public async Task GetAllAsync_FileOpenedByOtherProcess_ThrowsDataAccessException var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.GetAllAsync(CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.GetAllAsync(CancellationToken.None)); } } @@ -117,7 +117,7 @@ public async Task GetAllAsync_JsonException_ThrowsRepositoryCorruptedException() fakeSerializer.Object, fakeLoggerFactory); - RepositoryCorruptedException e = await Assert.ThrowsExceptionAsync(() => sut.GetAllAsync(CancellationToken.None)); + RepositoryCorruptedException e = await Assert.ThrowsExactlyAsync(() => sut.GetAllAsync(CancellationToken.None)); Assert.AreSame(exception, e.InnerException); fakeLogger.Verify(l => l.Error(exception, It.IsAny())); } @@ -199,7 +199,7 @@ public async Task TryGetByIdAsync_DuplicatesDetected_ThrowsRepositoryCorruptedEx var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.TryGetByIdAsync(fakeInstalledPluginInfo.Metadata.Identity.Id, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.TryGetByIdAsync(fakeInstalledPluginInfo.Metadata.Identity.Id, CancellationToken.None)); } #endregion @@ -255,7 +255,7 @@ public async Task ExistsAsync_DuplicatesDetected_ThrowsRepositoryCorruptedExcept var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.ExistsAsync(fakeInstalledPluginInfo, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.ExistsAsync(fakeInstalledPluginInfo, CancellationToken.None)); } #endregion @@ -327,7 +327,7 @@ public async Task AddAsync_AlreadyRegisteredPlugin_ThrowsInvalidOperationExcepti var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.AddAsync(plugin1, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.AddAsync(plugin1, CancellationToken.None)); } #endregion @@ -343,7 +343,7 @@ public async Task DeleteAsync_FileNotExist_ThrowsInvalidOperationException() var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync( + await Assert.ThrowsExactlyAsync( () => sut.DeleteAsync(fakeInstalledPluginInfo, CancellationToken.None)); } @@ -394,7 +394,7 @@ public async Task DeleteAsync_PluginNotRegistered_ThrowsInvalidOperationExceptio var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.DeleteAsync(plugin2, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.DeleteAsync(plugin2, CancellationToken.None)); } @@ -417,7 +417,7 @@ public async Task DeleteAsync_PluginWithSameIdButDifferentVersionRegistered_Thro var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.DeleteAsync(plugin2, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.DeleteAsync(plugin2, CancellationToken.None)); } #endregion @@ -435,7 +435,7 @@ public async Task UpdateAsync_DifferentIDs_ThrowsInvalidOperationException() var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync( + await Assert.ThrowsExactlyAsync( () => sut.UpdateAsync(fakeInstalledPluginInfo, fakeUpdatedPluginInfo, CancellationToken.None)); } @@ -450,7 +450,7 @@ public async Task UpdateAsync_FileNotExist_ThrowsInvalidOperationException() var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync( + await Assert.ThrowsExactlyAsync( () => sut.UpdateAsync(fakeInstalledPluginInfo, toUpdate, CancellationToken.None)); } @@ -469,7 +469,7 @@ public async Task UpdateAsync_CurrentPluginNotRegistered_ThrowsInvalidOperationE var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.UpdateAsync(current, toUpdate, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.UpdateAsync(current, toUpdate, CancellationToken.None)); } [TestMethod] @@ -490,7 +490,7 @@ public async Task UpdateAsync_ToUpdatePluginAlreadyRegistered_ThrowsInvalidOpera var sut = new FileBackedPluginRegistry(this.registryRoot, fakeSerializer.Object); - await Assert.ThrowsExceptionAsync(() => sut.UpdateAsync(current, toUpdate, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sut.UpdateAsync(current, toUpdate, CancellationToken.None)); } [TestMethod] diff --git a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests.csproj b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests.csproj index 62fb238b3..a49e24406 100644 --- a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests.csproj +++ b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests.csproj @@ -9,12 +9,15 @@ - - - - - - + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/PluginSourcesRepositoryTests.cs b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/PluginSourcesRepositoryTests.cs index 89a72ecb8..b6047bb97 100644 --- a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/PluginSourcesRepositoryTests.cs +++ b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Runtime.Tests/PluginSourcesRepositoryTests.cs @@ -94,7 +94,7 @@ public void Add_Single_NullItem_ThrowsArgumentNullException() var repo = new PluginSourceRepository(); PluginSource? pluginSource = null; - Assert.ThrowsException(() => repo.Add(pluginSource)); + Assert.ThrowsExactly(() => repo.Add(pluginSource)); } #endregion @@ -179,7 +179,7 @@ public void Add_Mutiple_ThrowsArgumentNullException() var repo = new PluginSourceRepository(); PluginSource[]? pluginSources = null; - Assert.ThrowsException(() => repo.Add(pluginSources)); + Assert.ThrowsExactly(() => repo.Add(pluginSources)); } #endregion @@ -270,7 +270,7 @@ public void Remove_Single_ThrowsArgumentNullException() var repo = new PluginSourceRepository(); PluginSource? pluginSource = null; - Assert.ThrowsException(() => repo.Remove(pluginSource)); + Assert.ThrowsExactly(() => repo.Remove(pluginSource)); } #endregion @@ -364,7 +364,7 @@ public void Remove_Multiple_ThrowsArgumentNullException() var repo = new PluginSourceRepository(); PluginSource[]? pluginSources = null; - Assert.ThrowsException(() => repo.Remove(pluginSources)); + Assert.ThrowsExactly(() => repo.Remove(pluginSources)); } #endregion diff --git a/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/Microsoft.Performance.Toolkit.Plugins.Cli.Tests.csproj b/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/Microsoft.Performance.Toolkit.Plugins.Cli.Tests.csproj index 55b121a74..ce45268b1 100644 --- a/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/Microsoft.Performance.Toolkit.Plugins.Cli.Tests.csproj +++ b/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/Microsoft.Performance.Toolkit.Plugins.Cli.Tests.csproj @@ -8,14 +8,18 @@ - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + From 9c40955cb24c8f763bf643b4ed764e375c79df9c Mon Sep 17 00:00:00 2001 From: Jing Xia <185141590+xj-ms@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:35:32 -0700 Subject: [PATCH 2/2] Add missting UnitTest attributes and fix a test --- .github/workflows/ci.yml | 2 +- .github/workflows/main_tests_status.yml | 2 +- .../Options/PluginOptionsSystemTests.cs | 2 +- .../Options/PluginOptionsSystem.cs | 39 +++++++++++++++++++ .../PluginIdentityTest.cs | 2 + .../PluginMetadataSerializationTests.cs | 2 + .../PluginManifestSerializationTests.cs | 2 + 7 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b94263e3..32b33d554 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,6 @@ jobs: - name: Build solution run: dotnet build "${{ github.workspace }}/src/SDK.sln" --no-restore -c Release - name: Run tests - run: dotnet test "${{ github.workspace }}/src/SDK.sln" -c Release --filter "TestCategory~Unit|TestCategory~Integration|TestCategory~Functional" --no-build --verbosity normal + run: dotnet test "${{ github.workspace }}/src/SDK.sln" -c Release --no-build --verbosity normal - name: Build samples run: ls "${{ github.workspace }}/samples/**/*.sln" | % { dotnet build $_.FullName -c Release } diff --git a/.github/workflows/main_tests_status.yml b/.github/workflows/main_tests_status.yml index d9ea66142..55e9b4f6d 100644 --- a/.github/workflows/main_tests_status.yml +++ b/.github/workflows/main_tests_status.yml @@ -28,4 +28,4 @@ jobs: - name: Build solution run: dotnet build "${{ github.workspace }}/src/SDK.sln" --no-restore -c Release - name: Run tests - run: dotnet test "${{ github.workspace }}/src/SDK.sln" -c Release --filter "TestCategory~Unit|TestCategory~Integration|TestCategory~Functional" --no-build --verbosity normal + run: dotnet test "${{ github.workspace }}/src/SDK.sln" -c Release --no-build --verbosity normal diff --git a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs index 7793fca78..a1eec15d4 100644 --- a/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs +++ b/src/Microsoft.Performance.SDK.Runtime.Tests/Options/PluginOptionsSystemTests.cs @@ -104,7 +104,7 @@ public void BadFilePath_ThrowsArgumentException(string filePath) { Assert.ThrowsExactly(() => { - PluginOptionsSystem.CreateForFile(null, (_) => new NullLogger()); + PluginOptionsSystem.CreateForFile(filePath, (_) => new NullLogger()); }); } diff --git a/src/Microsoft.Performance.SDK.Runtime/Options/PluginOptionsSystem.cs b/src/Microsoft.Performance.SDK.Runtime/Options/PluginOptionsSystem.cs index 9d0fa4a8d..d9f667cc0 100644 --- a/src/Microsoft.Performance.SDK.Runtime/Options/PluginOptionsSystem.cs +++ b/src/Microsoft.Performance.SDK.Runtime/Options/PluginOptionsSystem.cs @@ -64,6 +64,8 @@ public static PluginOptionsSystem CreateForFile( string filePath, Func loggerFactory) { + ValidateFilePath(filePath); + var directory = Path.GetDirectoryName(filePath); if (string.IsNullOrEmpty(directory)) @@ -80,6 +82,43 @@ public static PluginOptionsSystem CreateForFile( return new PluginOptionsSystem(loader, saver, registry); } + /// + /// Validates that is well-formed, throwing an + /// if it contains invalid characters or is + /// otherwise malformed. This check is performed up-front so that malformed + /// paths consistently result in an instead of + /// leaking lower-level exceptions (e.g. ) or, worse, + /// silently succeeding. + /// + private static void ValidateFilePath(string filePath) + { + if (string.IsNullOrWhiteSpace(filePath)) + { + throw new ArgumentException("File path cannot be null, empty, or consist only of white-space characters.", nameof(filePath)); + } + + if (filePath.IndexOfAny(Path.GetInvalidPathChars()) >= 0) + { + throw new ArgumentException("The file path contains invalid characters.", nameof(filePath)); + } + + string fileName = Path.GetFileName(filePath); + if (!string.IsNullOrEmpty(fileName) && fileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) + { + throw new ArgumentException("The file name portion of the file path contains invalid characters.", nameof(filePath)); + } + + // A ':' is only valid as the drive-letter separator (e.g. "C:\..."). Anywhere + // else it produces a malformed path (e.g. ":C:\foo" or "C:\foo\:bar.json"), + // which some file system APIs surface as an IOException rather than an + // ArgumentException. + int colonIndex = filePath.IndexOf(':'); + if (colonIndex >= 0 && colonIndex != 1) + { + throw new ArgumentException("The file path contains a ':' character in a position other than a drive letter separator.", nameof(filePath)); + } + } + /// /// Creates a new instance of that does not persist options. /// diff --git a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginIdentityTest.cs b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginIdentityTest.cs index 3cc6fc611..0c1e8ae3a 100644 --- a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginIdentityTest.cs +++ b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginIdentityTest.cs @@ -1,11 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using Microsoft.Performance.Testing; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Microsoft.Performance.Toolkit.Plugins.Core.Tests; [TestClass] +[UnitTest] public class PluginIdentityTest { [TestMethod] diff --git a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginMetadataSerializationTests.cs b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginMetadataSerializationTests.cs index 644768a26..b2cfeade1 100644 --- a/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginMetadataSerializationTests.cs +++ b/src/PluginsSystem/Microsoft.Performance.Toolkit.Plugins.Core.Tests/PluginMetadataSerializationTests.cs @@ -2,12 +2,14 @@ // Licensed under the MIT License. using Microsoft.Performance.Toolkit.Plugins.Core.Metadata; +using Microsoft.Performance.Testing; using Microsoft.VisualStudio.TestTools.UnitTesting; using Fixture = AutoFixture.Fixture; namespace Microsoft.Performance.Toolkit.Plugins.Core.Tests; [TestClass] +[UnitTest] public sealed class PluginMetadataSerializationTests { private Fixture? fixture = null; diff --git a/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/PluginManifestSerializationTests.cs b/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/PluginManifestSerializationTests.cs index d8d21a445..ed036e021 100644 --- a/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/PluginManifestSerializationTests.cs +++ b/src/PluginsSystem/Tools/Microsoft.Performance.Toolkit.Plugins.Cli.Tests/PluginManifestSerializationTests.cs @@ -3,11 +3,13 @@ using Microsoft.Performance.Toolkit.Plugins.Cli.Manifest; using Microsoft.Performance.Toolkit.Plugins.Core.Tests; +using Microsoft.Performance.Testing; using Fixture = AutoFixture.Fixture; namespace Microsoft.Performance.Toolkit.Plugins.Cli.Tests; [TestClass] +[UnitTest] public sealed class PluginManifestSerializationTest { private Fixture? fixture = null;