Skip to content
Merged
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 @@ -331,16 +331,14 @@ private static bool IsExactInstanceOfTypeFailing([NotNullWhen(false)] object? va
[DoesNotReturn]
private static void ThrowAssertIsExactInstanceOfTypeFailed(object? value, Type? expectedType, string userMessage)
{
string finalMessage = userMessage;
if (expectedType is not null && value is not null)
{
finalMessage = string.Format(
string finalMessage = expectedType is not null
? string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.IsExactInstanceOfFailMsg,
userMessage,
expectedType.ToString(),
value.GetType().ToString());
}
value?.GetType().ToString() ?? "null")
: userMessage;
Comment thread
Evangelink marked this conversation as resolved.

ThrowAssertFailed("Assert.IsExactInstanceOfType", finalMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,14 @@ private static bool IsInstanceOfTypeFailing([NotNullWhen(false)] object? value,
[DoesNotReturn]
private static void ThrowAssertIsInstanceOfTypeFailed(object? value, Type? expectedType, string userMessage)
{
string finalMessage = userMessage;
if (expectedType is not null && value is not null)
{
finalMessage = string.Format(
string finalMessage = expectedType is not null
? string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.IsInstanceOfFailMsg,
userMessage,
expectedType.ToString(),
value.GetType().ToString());
}
value?.GetType().ToString() ?? "null")
: userMessage;
Comment thread
Evangelink marked this conversation as resolved.

ThrowAssertFailed("Assert.IsInstanceOfType", 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'. Expected exact type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<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 Expected exact type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<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)} Expected exact type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<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'. Expected exact type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<null>.");
}

public void IsExactInstanceOfTypeUsingGenericType_WhenTypeMismatch_Fails()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void InstanceOfTypeShouldFailWhenValueIsNull()
{
Action action = () => Assert.IsInstanceOfType(null, typeof(AssertTests));
action.Should().Throw<AssertFailedException>()
.WithMessage("Assert.IsInstanceOfType failed. 'value' expression: 'null'.");
.WithMessage("Assert.IsInstanceOfType failed. 'value' expression: 'null'. Expected type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<null>.");
}

public void InstanceOfTypeShouldFailWhenTypeIsNull()
Expand All @@ -37,7 +37,7 @@ public void InstanceOfType_WithStringMessage_ShouldFailWhenValueIsNull()
{
Action action = () => Assert.IsInstanceOfType(null, typeof(AssertTests), "User-provided message");
action.Should().Throw<AssertFailedException>()
.WithMessage("Assert.IsInstanceOfType failed. 'value' expression: 'null'. User-provided message");
.WithMessage("Assert.IsInstanceOfType failed. 'value' expression: 'null'. User-provided message Expected type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<null>.");
}

public void InstanceOfType_WithStringMessage_ShouldFailWhenTypeIsNull()
Expand All @@ -63,7 +63,7 @@ public async Task InstanceOfType_WithInterpolatedString_ShouldFailWhenValueIsNul
DateTime dateTime = DateTime.Now;
Func<Task> action = async () => Assert.IsInstanceOfType(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.IsInstanceOfType 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.IsInstanceOfType 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)} Expected type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<null>.");
o.WasToStringCalled.Should().BeTrue();
}

Expand Down Expand Up @@ -108,7 +108,7 @@ public void IsInstanceOfTypeUsingGenericType_WhenValueIsNull_Fails()
{
Action action = () => Assert.IsInstanceOfType<AssertTests>(null);
action.Should().Throw<AssertFailedException>()
.WithMessage("Assert.IsInstanceOfType failed. 'value' expression: 'null'.");
.WithMessage("Assert.IsInstanceOfType failed. 'value' expression: 'null'. Expected type:<Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.AssertTests>. Actual type:<null>.");
}

public void IsInstanceOfTypeUsingGenericType_WhenTypeMismatch_Fails()
Expand Down