Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert("{","x") throws System.FormatException
See original GitHub issueDescribe the bug
A clear and concise description of what the bug is.
Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert("{","x")
throws System.FormatException
instead of AssertFailedException
.
To Reproduce
StringAssert.Contains(":-{","x");
See: https://github.com/nonZero/StringAssert_Demo
Exceptions (if any)
Test method threw exception System.FormatException, but exception Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException was expected. Exc...
Test method threw exception System.FormatException, but exception Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException was expected. Exception message: System.FormatException: Input string was not in a correct format.
at System.Text.ValueStringBuilder.ThrowFormatError()
at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at StringAssert_Demo.UnitTest1.Test_StringAssert_DoesNotContain_WithCurly() in .../StringAssert_Demo/StringAssertUnitTest.cs:line 26
Further technical details
.NET SDK (reflecting any global.json):
Version: 6.0.102
Commit: 49861cb924
Runtime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /usr/share/dotnet/sdk/6.0.102/
Host (useful for support):
Version: 6.0.2
Commit: 839cdfb0ec
.NET SDKs installed:
6.0.102 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.16 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.16 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
c# - StringAssert.Contains("{", needle) throws System. ...
I am using C# with .NET Core and Microsoft.VisualStudio.TestTools.UnitTesting . When calling: StringAssert.Contains(my_text, my_needle);.
Read more >Assert.ThrowsException Method
Tests whether the code specified by delegate action throws exact given exception of type T (and not of derived type) and throws AssertFailedException...
Read more >Unit Testing Exceptions in C#
In this article we've gone over how to unit test our code that will throw exceptions in a deterministic way. We can either...
Read more >问答- 腾讯云开发者社区-腾讯云
Test method MyTest threw exception: System.FormatException: Input string was not in a correct format. at System.Text.ValueStringBuilder.
Read more >Most Complete MSTest Unit Testing Framework Cheat Sheet
Most complete MSTest Unit Testing Framework cheat sheet. All you need to to know- the most basic operations to the most advanced configurations....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nice catch @KalleOlaviNiemitalo! I will do a follow-up fix.
That is an incomplete fix; the parameters array might not be empty. Consider
StringAssert.Contains("{", "x", "message {0}", "param");
.