Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 测试模型属性的正则表达式_Regex_Asp.net Mvc 3_Entity Framework 4 - Fatal编程技术网

Regex 测试模型属性的正则表达式

Regex 测试模型属性的正则表达式,regex,asp.net-mvc-3,entity-framework-4,Regex,Asp.net Mvc 3,Entity Framework 4,这是我模型的一部分 [RegularExpression(@"^([a-z][a-z0-9.-]+)\\((?! +\r?$)[a-z0-9 ]+)\r?$", ErrorMessage = @"Enter the account in domain\account format.")] [ScaffoldColumn(true)] [DisplayName("Account Name")] string Col_DomainName { get; set; } 我想写

这是我模型的一部分

[RegularExpression(@"^([a-z][a-z0-9.-]+)\\((?! +\r?$)[a-z0-9 ]+)\r?$", ErrorMessage = @"Enter the account in domain\account format.")]
    [ScaffoldColumn(true)]
    [DisplayName("Account Name")]
    string Col_DomainName { get; set; }
我想写一个单元测试,在那里我可以测试这个。我该怎么做?我正在使用NUnit


谢谢

现在还不清楚问题是什么……您不需要为
RegularExpression
等类编写单元测试。您应该为已经编写的代码编写单元测试。这通常是刚开始单元测试的人所犯的错误。我编写正则表达式来验证帐户名字段。我应该能够测试我的正则表达式是否有效。我不明白为什么我不应该测试。我不是在测试实际验证是否有效,而是在测试正则表达式。