Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StackOverflowException in StringAssert.DoesNotMatch #806

Merged
merged 1 commit into from
Mar 31, 2021
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
2 changes: 1 addition & 1 deletion src/TestFramework/MSTest.Core/Assertions/StringAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public static void DoesNotMatch(string value, Regex pattern)
/// </exception>
public static void DoesNotMatch(string value, Regex pattern, string message)
{
DoesNotMatch(value, pattern, message);
DoesNotMatch(value, pattern, message, null);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.Assertions
extern alias FrameworkV2;

using System;
using System.Text.RegularExpressions;

using MSTestAdapter.TestUtilities;
using Assert = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
Expand Down Expand Up @@ -60,6 +61,16 @@ public void StringAssertEndsWith()
TestFrameworkV1.StringAssert.Contains(ex.Message, "StringAssert.EndsWith failed");
}

[TestMethod]
public void StringAssertDoesNotMatch()
{
string actual = "The quick brown fox jumps over the lazy dog.";
Regex doesMatch = new Regex("quick brown fox");
var ex = ActionUtility.PerformActionAndReturnException(() => TestFrameworkV2.StringAssert.DoesNotMatch(actual, doesMatch));
Assert.IsNotNull(ex);
TestFrameworkV1.StringAssert.Contains(ex.Message, "StringAssert.DoesNotMatch failed");
}

[TestMethod]
public void StringAssertContainsIgnoreCase()
{
Expand Down