Repository navigation
Migrate Microsoft.TemplateSearch.Common.UnitTests to MSTest.Sdk on MTP - #54787
Merged
Evangelink merged 4 commits intoJun 17, 2026
Merged
Evangelink merged 4 commits into
Evangelink merged 4 commits into
Conversation
Convert from xUnit (v3) to MSTest via MSTest.Sdk (MTP on by default), matching the TemplateEngine migration pattern (dotnet#54758/dotnet#54759/dotnet#54761): - csproj uses Sdk="MSTest.Sdk", IsTestProject=true. - [Fact] -> [TestMethod]; [TestClass] added. - Assertions mapped: Equal->AreEqual, True/False->IsTrue/IsFalse, NotNull->IsNotNull, IsAssignableFrom<T>->IsInstanceOfType<T>, Single->ContainsSingle (predicate-first overload where applicable), IEnumerable Equal->AreSequenceEqual. - IClassFixture<EnvironmentSettingsHelper> -> static Lazy<EnvironmentSettingsHelper> + [ClassCleanup]; EnvironmentSettingsHelper's IMessageSink ctor arg satisfied by a local no-op NullMessageSink (+ GlobalUsings alias for Xunit.Sdk.IMessageSink), since the shared TestHelper still references xunit.v3 and is out of scope for this migration. - TestContext.Current.CancellationToken -> instance TestContext.CancellationToken. Parallelization left to the repo-wide MSTest.Sdk default (dotnet#54766). All 17 tests pass. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates Microsoft.TemplateSearch.Common.UnitTests from xUnit v3 to MSTest on Microsoft.Testing.Platform by switching the project to MSTest.Sdk and updating fixtures, assertions, and cancellation token usage to MSTest patterns consistent with other TemplateEngine test migrations.
Changes:
- Switch the test project SDK to
MSTest.Sdkand mark it as a test project. - Convert xUnit attributes/assertions to MSTest (
[Fact]→[TestMethod],Assert.*mappings) and move cancellation tokens toTestContext.CancellationToken. - Replace
IClassFixture<EnvironmentSettingsHelper>with a per-class staticLazy<EnvironmentSettingsHelper>plus[ClassCleanup], and add a localNullMessageSink+ global aliases for xUnit’sIMessageSink.
Show a summary per file
| File | Description |
|---|---|
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/Microsoft.TemplateSearch.Common.UnitTests.csproj | Switches project to MSTest.Sdk and marks it as a test project. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/GlobalUsings.cs | Adds xUnit IMessageSink aliases to construct EnvironmentSettingsHelper without xUnit global usings. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/NullMessageSink.cs | Introduces a no-op message sink for EnvironmentSettingsHelper construction under MSTest. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/TemplateSearchCoordinatorTests.cs | Converts test class to MSTest and updates assertions/cancellation token usage. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/TemplateSearchCacheReaderTests.cs | Converts test class to MSTest and updates assertions/fixture lifecycle. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/NuGetMetadataSearchProviderTests.cs | Converts test class to MSTest and updates assertions/cancellation token usage. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/AllComponents.cs | Converts to MSTest and updates sequence assertions. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 2
Member
Author
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <[email protected]>
…tionTests) PR dotnet#54766 enabled the Recommended MSTest analyzers as errors; dotnet#54758 merged shortly after with violations that are now build errors, leaving main red and blocking all open migration PRs. Fix the two affected files: - CommandResultAssertions.MSTest.cs: MSTEST0037 (IsTrue(a==b)->AreEqual, IsFalse(a==b) ->AreNotEqual) and MSTEST0023 (IsTrue(!x)->IsFalse(x)). - LocalizeTemplateTests.cs: MSTEST0037 (AreEqual(n, x.Length)->HasCount(n, x)). Co-authored-by: Copilot <[email protected]> (cherry picked from commit 6ac4ef0)
Evangelink
enabled auto-merge (squash)
June 17, 2026 08:46
JeremyKuhne
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates Microsoft.TemplateSearch.Common.UnitTests from xUnit (v3) to MSTest on MTP via
MSTest.Sdk, following the same pattern as #54758 / #54759 / #54761.Changes
[Fact]->[TestMethod]+[TestClass]; assertions mapped to MSTest:Equal->AreEqual,True/False->IsTrue/IsFalse,NotNull->IsNotNullIsAssignableFrom<T>->IsInstanceOfType<T>(assignable semantics preserved)Single->ContainsSingle(predicate-first overload where a predicate was used)Assert.EqualoverIEnumerable->Assert.AreSequenceEqualIClassFixture<EnvironmentSettingsHelper>-> staticLazy<EnvironmentSettingsHelper>+[ClassCleanup](per-class shared instance, matching xUnit's class-fixture scope).EnvironmentSettingsHelper's ctor takes anXunit.Sdk.IMessageSink; satisfied with a local no-opNullMessageSinkand aGlobalUsingsalias — identical to Migrate Microsoft.TemplateEngine.Utils.UnitTests to MSTest.Sdk on MTP #54759. The sharedMicrosoft.TemplateEngine.TestHelperstill referencesxunit.v3and is out of scope here.TestContext.Current.CancellationToken-> instanceTestContext.CancellationToken(property injection).Notes
MSTest.Sdkdefault (Set MSTest.Sdk-wide defaults: UseMSTestSdk, method-level parallelization, Recommended analyzers #54766) — no per-project[assembly: Parallelize].Verification
Relates to #52914.