|
12 | 12 | using System.Collections; |
13 | 13 | using System.Runtime.Serialization; |
14 | 14 | using System.Runtime.Serialization.Formatters; |
| 15 | +using System.Text.RegularExpressions; |
15 | 16 | using Xunit; |
16 | 17 |
|
17 | 18 | namespace System.Net.Mail.Tests |
@@ -80,7 +81,12 @@ public void TestConstructorWithStringArgument() |
80 | 81 | Assert.Equal(0, se.Data.Keys.Count); |
81 | 82 | Assert.Null(se.InnerException); |
82 | 83 | 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 | + |
84 | 90 | Assert.Equal(SmtpStatusCode.GeneralFailure, se.StatusCode); |
85 | 91 | } |
86 | 92 |
|
@@ -112,7 +118,12 @@ public void TestConstructorWithStatusCodeAndStringArgument() |
112 | 118 | Assert.Equal(0, se.Data.Keys.Count); |
113 | 119 | Assert.Null(se.InnerException); |
114 | 120 | 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 | + |
116 | 127 | Assert.Equal((SmtpStatusCode)666, se.StatusCode); |
117 | 128 | } |
118 | 129 |
|
|
0 commit comments