Created
March 23, 2012 17:24
-
-
Save thoolihan/2172991 to your computer and use it in GitHub Desktop.
Example of NUnit TestCase Syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestCase("abcdefgH", Result = false)] | |
[TestCase("@Bcdefgh", Result = true)] | |
[TestCase("#Bcdefgh", Result = true)] | |
[TestCase("$Bcdefgh", Result = true)] | |
[TestCase("%Bcdefgh", Result = true)] | |
[TestCase("^Bcdefgh", Result = true)] | |
[TestCase("&Bcdefgh", Result = true)] | |
[TestCase("+Bcdefgh", Result = true)] | |
[TestCase("=Bcdefgh", Result = true)] | |
[TestCase("!Bcdefgh", Result = true)] | |
[TestCase("(Bcdefgh", Result = false)] | |
//Valid characters are @#$%^&+=! | |
public bool Password_must_contain_a_special_character(string password) | |
{ | |
Password = password; | |
var property = typeof(PasswordAttributeTest).GetProperty("Password"); | |
var attribute = (property.GetCustomAttributes(typeof(PasswordAttribute), true))[0] as PasswordAttribute; | |
attribute.Should().Not.Be.Null(); | |
var value = property.GetValue(this, new object[0]); | |
return attribute.IsValid(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment