Skip to content

[tests] Upgrade tests/msbuild to NUnit v4 Assert.That syntax - #25431

Merged
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/nunitv4-msbuild
May 15, 2026
Merged

rolfbjarne merged 1 commit into
mainfrom
dev/rolf/nunitv4-msbuild

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Convert classic NUnit assertions (Assert.AreEqual, Assert.IsTrue, Assert.IsNotNull, etc.) to NUnit v4's constraint-based Assert.That syntax in the msbuild test projects.

Also update package references to use centralized version properties from Directory.Build.props:

  • NUnit β†’ $(NUnitPackageVersion)
  • NUnit3TestAdapter β†’ $(NUnit3TestAdapterPackageVersion)
  • Microsoft.NET.Test.Sdk β†’ $(MicrosoftNETTestSdkPackageVersion)

Two shared files (tests/common/DotNet.cs, tests/common/mac/ProjectTestHelpers.cs) are also converted β€” the Assert.That constraint syntax is compatible with both NUnit 3 and 4, so other projects referencing these files are unaffected.

All tests-msbuild tests pass (495 passed, 0 failed).

πŸ€– Pull request created by Copilot

Convert classic NUnit assertions (Assert.AreEqual, Assert.IsTrue,
Assert.IsNotNull, etc.) to NUnit v4's constraint-based Assert.That
syntax across all msbuild test projects.

Also update NUnit package references to use centralized version
properties from Directory.Build.props.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
rolfbjarne marked this pull request as ready for review May 14, 2026 17:58
Copilot AI review requested due to automatic review settings May 14, 2026 17:58
@rolfbjarne
rolfbjarne enabled auto-merge (squash) May 14, 2026 17:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the MSBuild test suites by moving them to NUnit’s constraint-based assertion style (Assert.That) and by centralizing test package versions via properties in Directory.Build.props (bringing these projects in line with other test projects in the repo).

Changes:

  • Converted classic NUnit assertions (Assert.AreEqual, Assert.IsTrue, etc.) to constraint syntax across tests/msbuild and shared test helpers.
  • Updated MSBuild test project package references to use centralized version properties ($(NUnitPackageVersion), $(NUnit3TestAdapterPackageVersion), $(MicrosoftNETTestSdkPackageVersion)).
  • Updated shared test utilities in tests/common to use Assert.That (compatible with NUnit 3/4).

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj Switch NUnit/Test SDK package references to centralized version properties.
tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/TestBase.cs Convert helper assertions to Assert.That and adjust assertion messages.
tests/msbuild/Xamarin.MacDev.Tests/TargetTests/TargetTests.cs Convert target test assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tests/TargetTests/DetectSigningIdentityTests.cs Convert assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tests/TargetTests/CollectAppManifestsTests.cs Convert assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/Xamarin.MacDev.Tasks.Tests.csproj Switch NUnit/Test SDK package references to centralized version properties.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/UtilityTests.cs Convert assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TestHelpers/TestBase.cs Convert engine/task execution assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/ResolveNativeReferencesTaskTest.cs Convert assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/ReadAppManifestTaskTests.cs Convert assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/PropertyListEditorTaskTests.cs Convert plist comparison assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/ParseBundlerArgumentsTests.cs Convert argument parsing assertions (including equivalents) to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/MergeAppBundleTaskTest.cs Convert bundle merge assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/LocalizationStringTest.cs Convert translation/resource assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/IBToolTaskTests.cs Convert IBTool execution/resource assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetPropertyListValueTaskTests.cs Convert value assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetBundleNameTaskTests.cs Convert assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetAvailableDevicesTest.cs Convert device parsing/execution assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_iOS.cs Convert assertions to constraint syntax in iOS plist tests.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_iOS_AppExtension.cs Convert assertions to constraint syntax in app extension plist tests.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs Convert core plist assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/DetectSigningIdentityTaskTests.cs Convert assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/DetectSdkLocationsTaskTests.cs Convert assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CreateBindingResourceTaskTests.cs Convert extraction/resource assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/ComputeCodesignItemsTaskTests.cs Convert warning-count and related assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs Convert entitlement validation assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CompileAppManifestTaskTests.cs Convert manifest/plist assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CollectITunesArtworkTaskTests.cs Convert artwork assertions to constraint syntax.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/BundleResourceTests.cs Convert virtual path assertions to Assert.That.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/ACToolTaskTest.cs Convert asset catalog task assertions to Assert.That.
tests/common/mac/ProjectTestHelpers.cs Convert shared helper assertions to Assert.That.
tests/common/DotNet.cs Convert shared dotnet command assertions to constraint syntax.
Comments suppressed due to low confidence (4)

tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs:134

  • These Assert.That calls have the expected/actual order inverted (constant/expected value passed as the actual argument, and the plist value inside Is.EqualTo(...)). This will produce confusing failure messages; pass the plist value as the actual and the constant/expected as the constraint value instead.
			Assert.That (CompiledPlist.ContainsKey (ManifestKeys.CFBundleName), "#1");
			Assert.That (appBundleName, Is.EqualTo (CompiledPlist.Get<PString> (ManifestKeys.CFBundleName)?.Value), "#2");
		}

tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs:141

  • These Assert.That calls have the expected/actual order inverted (constant/expected value passed as the actual argument, and the plist value inside Is.EqualTo(...)). This will produce confusing failure messages; pass the plist value as the actual and the constant/expected as the constraint value instead.
			Assert.That (CompiledPlist.ContainsKey (ManifestKeys.CFBundleIdentifier), "#1");
			Assert.That (bundleIdentifier, Is.EqualTo (CompiledPlist.Get<PString> (ManifestKeys.CFBundleIdentifier)?.Value), "#2");
		}

tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs:155

  • These Assert.That calls have the expected/actual order inverted (constant/expected value passed as the actual argument, and the plist value inside Is.EqualTo(...)). This will produce confusing failure messages; pass the plist value as the actual and the constant/expected as the constraint value instead.
			Assert.That (CompiledPlist.ContainsKey (ManifestKeys.CFBundlePackageType), "#1");
			Assert.That ("APPL", Is.EqualTo (CompiledPlist.Get<PString> (ManifestKeys.CFBundlePackageType)?.Value), "#2");
		}

tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs:162

  • These Assert.That calls have the expected/actual order inverted (constant/expected value passed as the actual argument, and the plist value inside Is.EqualTo(...)). This will produce confusing failure messages; pass the plist value as the actual and the constant/expected as the constraint value instead.
			Assert.That (CompiledPlist.ContainsKey (ManifestKeys.CFBundleSignature), "#1");
			Assert.That ("????", Is.EqualTo (CompiledPlist.Get<PString> (ManifestKeys.CFBundleSignature)?.Value), "#2");
		}


var archived = PDictionary.FromFile (archivedEntitlements);
Assert.IsTrue (compiled.ContainsKey ("application-identifier"), "archived");
Assert.That (compiled.ContainsKey ("application-identifier"), Is.True, "archived");
Comment on lines 125 to 127
Assert.That (CompiledPlist.ContainsKey (ManifestKeys.CFBundleExecutable), "#1");
Assert.AreEqual (CompiledPlist.Get<PString> (ManifestKeys.CFBundleExecutable)?.Value, assemblyName, "#2");
Assert.That (assemblyName, Is.EqualTo (CompiledPlist.Get<PString> (ManifestKeys.CFBundleExecutable)?.Value), "#2");
}
{
Assert.That (CompiledPlist.ContainsKey (ManifestKeys.CFBundleName), "#1");
Assert.AreEqual (CompiledPlist.Get<PString> (ManifestKeys.CFBundleName)?.Value, appBundleName, "#2");
Assert.That (appBundleName, Is.EqualTo (CompiledPlist.Get<PString> (ManifestKeys.CFBundleName)?.Value), "#2");
{
Assert.That (CompiledPlist.ContainsKey (ManifestKeys.CFBundlePackageType), "#1");
Assert.AreEqual (CompiledPlist.Get<PString> (ManifestKeys.CFBundlePackageType)?.Value, "XPC!", "#2");
Assert.That ("XPC!", Is.EqualTo (CompiledPlist.Get<PString> (ManifestKeys.CFBundlePackageType)?.Value), "#2");
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

βœ… [PR Build #5f5478d] Build passed (Detect API changes) βœ…

Pipeline on Agent
Hash: 5f5478d7efb8bc80bf373fba12244b6f11a6f4bf [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

βœ… [PR Build #5f5478d] Build passed (Build packages) βœ…

Pipeline on Agent
Hash: 5f5478d7efb8bc80bf373fba12244b6f11a6f4bf [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

βœ… API diff for current PR / commit

NET (empty diffs)

βœ… API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 5f5478d7efb8bc80bf373fba12244b6f11a6f4bf [PR build]

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beep beep boop πŸ€–

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

βœ… [PR Build #5f5478d] Build passed (Build macOS tests) βœ…

Pipeline on Agent
Hash: 5f5478d7efb8bc80bf373fba12244b6f11a6f4bf [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

πŸš€ [CI Build #5f5478d] Test results πŸš€

Test results

βœ… All tests passed on VSTS: test results.

πŸŽ‰ All 175 tests passed πŸŽ‰

Tests counts

βœ… cecil: All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (tvOS): All 1 tests passed. (⚠️ Html Report Publish failed ⚠️) Download
βœ… framework: All 2 tests passed. Html Report (VSDrops) Download
βœ… fsharp: All 4 tests passed. Html Report (VSDrops) Download
βœ… generator: All 5 tests passed. Html Report (VSDrops) Download
βœ… interdependent-binding-projects: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
βœ… introspection: All 6 tests passed. [attempt 2] Html Report (VSDrops) Download
βœ… linker: All 44 tests passed. Html Report (VSDrops) Download
βœ… monotouch (iOS): All 16 tests passed. Html Report (VSDrops) Download
βœ… monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
βœ… monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
βœ… monotouch (tvOS): All 16 tests passed. [attempt 2] Html Report (VSDrops) Download
βœ… msbuild: All 2 tests passed. Html Report (VSDrops) Download
βœ… sharpie: All 1 tests passed. (⚠️ Html Report Publish failed ⚠️) Download
βœ… windows: All 3 tests passed. Html Report (VSDrops) Download
βœ… xcframework: All 4 tests passed. Html Report (VSDrops) Download
βœ… xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

βœ… Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
βœ… Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
βœ… Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
βœ… Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
βœ… Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

βœ… Linux build succeeded

Pipeline on Agent
Hash: 5f5478d7efb8bc80bf373fba12244b6f11a6f4bf [PR build]

@rolfbjarne
rolfbjarne merged commit 44c6b88 into main May 15, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants