Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 248494c

Browse files
AlexRadchdanmoseley
authored andcommitted
Fixed netfx System.Net.Mail.Functional.Tests fails on non-English Windows (#28373)
1 parent c46fd93 commit 248494c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/System.Net.Mail/tests/Functional/SmtpExceptionTest.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Collections;
1313
using System.Runtime.Serialization;
1414
using System.Runtime.Serialization.Formatters;
15+
using System.Text.RegularExpressions;
1516
using Xunit;
1617

1718
namespace System.Net.Mail.Tests
@@ -80,7 +81,12 @@ public void TestConstructorWithStringArgument()
8081
Assert.Equal(0, se.Data.Keys.Count);
8182
Assert.Null(se.InnerException);
8283
Assert.NotNull(se.Message);
83-
Assert.NotEqual(-1, se.Message.IndexOf("'" + typeof(SmtpException).FullName + "'"));
84+
85+
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
86+
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
87+
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
88+
Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape(typeof(SmtpException).FullName) + @"[\p{Pf}\p{Po}]", se.Message);
89+
8490
Assert.Equal(SmtpStatusCode.GeneralFailure, se.StatusCode);
8591
}
8692

@@ -112,7 +118,12 @@ public void TestConstructorWithStatusCodeAndStringArgument()
112118
Assert.Equal(0, se.Data.Keys.Count);
113119
Assert.Null(se.InnerException);
114120
Assert.NotNull(se.Message);
115-
Assert.NotEqual(-1, se.Message.IndexOf("'" + typeof(SmtpException).FullName + "'"));
121+
122+
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
123+
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
124+
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
125+
Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape(typeof(SmtpException).FullName) + @"[\p{Pf}\p{Po}]", se.Message);
126+
116127
Assert.Equal((SmtpStatusCode)666, se.StatusCode);
117128
}
118129

0 commit comments

Comments
 (0)