Skip to content

Commit

Permalink
Fix StackOverflowException in StringAssert.DoesNotMatch (microsoft#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
quails4Eva committed Mar 31, 2021
1 parent c1cd55d commit 712986b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/TestFramework/MSTest.Core/Assertions/StringAssert.cs
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
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

0 comments on commit 712986b

Please sign in to comment.