Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,23 @@
expectedType.ToString(),
value.GetType().ToString());
}
else if (value is null)
{
// Ensure proper punctuation before adding the NULL message
string trimmedMessage = userMessage.TrimEnd();
if (trimmedMessage.Length > 0 && (trimmedMessage[^1] == '.' || trimmedMessage[^1] == '!' || trimmedMessage[^1] == '?'))

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,62): error CS0518: (NETCORE_ENGINEERING_TELEMETRY=Build) Predefined type 'System.Index' is not defined or imported

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,62): error CS0656: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing compiler required member 'System.Index..ctor'

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,62): error CS0518: (NETCORE_ENGINEERING_TELEMETRY=Build) Predefined type 'System.Index' is not defined or imported

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,62): error CS0656: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing compiler required member 'System.Index..ctor'

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,62): error CS0518: (NETCORE_ENGINEERING_TELEMETRY=Build) Predefined type 'System.Index' is not defined or imported

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,62): error CS0656: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing compiler required member 'System.Index..ctor'

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,91): error CS0518: (NETCORE_ENGINEERING_TELEMETRY=Build) Predefined type 'System.Index' is not defined or imported

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,91): error CS0656: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing compiler required member 'System.Index..ctor'

Check failure on line 348 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L348

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(348,62): error CS0518: (NETCORE_ENGINEERING_TELEMETRY=Build) Predefined type 'System.Index' is not defined or imported
{
finalMessage = $"{trimmedMessage} 'value' was NULL.";
}
else if (trimmedMessage.Length > 0)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)

Check failure on line 352 in src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs#L352

src/TestFramework/TestFramework/Assertions/Assert.IsExactInstanceOfType.cs(352,18): error IDE0045: (NETCORE_ENGINEERING_TELEMETRY=Build) 'if' statement can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0045)
{
finalMessage = $"{trimmedMessage}. 'value' was NULL.";
}
else
{
finalMessage = "'value' was NULL.";
}
}

ThrowAssertFailed("Assert.IsExactInstanceOfType", finalMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void ExactInstanceOfTypeShouldFailWhenValueIsNull()
{
Action action = () => Assert.IsExactInstanceOfType(null, typeof(AssertTests));
action.Should().Throw<AssertFailedException>()
.WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'.");
.WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. 'value' was NULL.");
}

public void ExactInstanceOfTypeShouldFailWhenTypeIsNull()
Expand Down Expand Up @@ -56,7 +56,7 @@ public void ExactInstanceOfType_WithStringMessage_ShouldFailWhenValueIsNull()
{
Action action = () => Assert.IsExactInstanceOfType(null, typeof(AssertTests), "User-provided message");
action.Should().Throw<AssertFailedException>()
.WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message");
.WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. 'value' was NULL.");
}

public void ExactInstanceOfType_WithStringMessage_ShouldFailWhenTypeIsNull()
Expand All @@ -82,7 +82,7 @@ public async Task ExactInstanceOfType_WithInterpolatedString_ShouldFailWhenValue
DateTime dateTime = DateTime.Now;
Func<Task> action = async () => Assert.IsExactInstanceOfType(null, typeof(AssertTests), $"User-provided message. {o}, {o,35}, {await GetHelloStringAsync()}, {new DummyIFormattable()}, {dateTime:tt}, {dateTime,5:tt}");
(await action.Should().ThrowAsync<AssertFailedException>())
.WithMessage($"Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. DummyClassTrackingToStringCalls, DummyClassTrackingToStringCalls, Hello, DummyIFormattable.ToString(), {string.Format(null, "{0:tt}", dateTime)}, {string.Format(null, "{0,5:tt}", dateTime)}");
.WithMessage($"Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. User-provided message. DummyClassTrackingToStringCalls, DummyClassTrackingToStringCalls, Hello, DummyIFormattable.ToString(), {string.Format(null, "{0:tt}", dateTime)}, {string.Format(null, "{0,5:tt}", dateTime)}. 'value' was NULL.");
o.WasToStringCalled.Should().BeTrue();
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public void IsExactInstanceOfTypeUsingGenericType_WhenValueIsNull_Fails()
{
Action action = () => Assert.IsExactInstanceOfType<AssertTests>(null);
action.Should().Throw<AssertFailedException>()
.WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'.");
.WithMessage("Assert.IsExactInstanceOfType failed. 'value' expression: 'null'. 'value' was NULL.");
}

public void IsExactInstanceOfTypeUsingGenericType_WhenTypeMismatch_Fails()
Expand Down
Loading