Skip to content

Instantly share code, notes, and snippets.

@thoolihan
Created March 23, 2012 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoolihan/2172991 to your computer and use it in GitHub Desktop.
Save thoolihan/2172991 to your computer and use it in GitHub Desktop.
Example of NUnit TestCase Syntax
[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