diff --git a/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs b/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs index 52cd825e62..aeba25c203 100644 --- a/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs +++ b/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs @@ -655,7 +655,7 @@ public static void DoesNotMatch(string value, Regex pattern) /// public static void DoesNotMatch(string value, Regex pattern, string message) { - DoesNotMatch(value, pattern, message); + DoesNotMatch(value, pattern, message, null); } /// diff --git a/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/StringAssertTests.cs b/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/StringAssertTests.cs index eefd9f3868..72f64e00a4 100644 --- a/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/StringAssertTests.cs +++ b/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/StringAssertTests.cs @@ -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; @@ -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() {