Skip to content

Improve Assert.AreSame message for nulls#7426

Merged
Evangelink merged 1 commit intomainfrom
dev/amauryleve/draft-assert-aresame
Apr 13, 2026
Merged

Improve Assert.AreSame message for nulls#7426
Evangelink merged 1 commit intomainfrom
dev/amauryleve/draft-assert-aresame

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Fix #7421

@Evangelink Evangelink marked this pull request as ready for review April 13, 2026 13:33
Copilot AI review requested due to automatic review settings April 13, 2026 13:33
@Evangelink Evangelink enabled auto-merge April 13, 2026 13:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 addresses #7421 by improving MSTest Assert.AreSame/Assert.AreNotSame failure messages when null values are involved, making failures easier to understand without needing to infer nullness from the inputs.

Changes:

  • Add localized resource strings for null-specific AreSame/AreNotSame failure cases.
  • Update Assert.AreSame/Assert.AreNotSame failure construction to include null-specific wording.
  • Add unit tests asserting the updated message output across string and interpolated-string overloads.
Show a summary per file
File Description
test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.AreSame.cs Adds test coverage for the new null-specific failure messages for AreSame and AreNotSame.
src/TestFramework/TestFramework/Assertions/Assert.AreSame.cs Implements null-specific message formatting for AreSame (expected/actual null) and AreNotSame (both null), including interpolated-string handler paths.
src/TestFramework/TestFramework/Resources/FrameworkMessages.resx Adds new resource entries used to format the null-specific assertion failure messages.
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.*.xlf Adds corresponding localization entries for the newly introduced resource keys across supported cultures.

Copilot's findings

  • Files reviewed: 16/16 changed files
  • Comments generated: 0

Comment thread src/TestFramework/TestFramework/Assertions/Assert.AreSame.cs
Comment thread src/TestFramework/TestFramework/Assertions/Assert.AreSame.cs
@Evangelink Evangelink merged commit 78fa087 into main Apr 13, 2026
16 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/draft-assert-aresame branch April 13, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve AreSame error messages in case of null values

3 participants