许多人可能已经意识到,正确验证电子邮件地址可能有点噩梦.您可以整天搜索与当前RFC标准匹配的C#正则表达式,并且您将找到不同的正则表达式,它们会产生不同的结果.
如果查看http://en.wikipedia.org/wiki/Email_address#Local_part,您将看到不允许在本地部分的开头或结尾处出现句点.也不允许连续两个时期.但是,以下NUnit测试证明System.Net.MailMessage允许您为某些无效的电子邮件地址格式实例化MailMessage对象.
[Test]
[TestCase(@"foobar@exampleserver")] //technically valid from the wiki article
[TestCase(@"jsmith@[192.168.2.1]")] //technically valid from the wiki article
[TestCase(@"niceandsimple@example.com")] //vanilla email address
[TestCase(@"very.common@example.com")] //also standard
[TestCase(@"a.little.lengthy.but.fine@dept.example.com")] //long with lots of periods
[TestCase(@"disposable.style.email.with+symbol@example.com")] //disposable with the + symbol
[TestCase(@"other.email-with-dash@example.com")] //period and dash in local part
[TestCase(@"user-test-hyphens@example-domain.com")] //lots of hyphens
[TestCase(@"!#$%&'*+-/=?^_`{|}~@example-domain.com")] //all these symbols are allowed in local part
[TestCase(@"ër_%?dev@g??il.com")] //characters outside the ascii range are permitted
[TestCase(@"""abcdefghixyz""@example.com")] //technically valid
//[TestCase(@"abc.""defghi"".xyz@example.com")] //technically valid, but .NET throws exception
public void CanCreateMailMessageObjectTest(string emailAddress) …
Run Code Online (Sandbox Code Playgroud) 方案:我在一个项目中有一个JenkinsFile,该项目使用以下方法引用共享管道库中的代码 @Library('my-lib')
语法。我想测试对库函数的更改,而无需执行对库回购的提交。
我意识到可以在include语句中定位库的特定版本或分支。我还意识到,可以通过使用Jenkins UI中的“重播”功能来修改JenkinsFile中的脚本而无需提交。如何在不需要对要测试的分支进行提交的情况下测试对共享库代码的修改?现在,我们必须对库代码进行每次调整都执行一次提交,并且我们不希望有总提交历史记录。换句话说,我们只希望提交我们知道正在工作的代码的库回购。