Skip to content

Instantly share code, notes, and snippets.

@plioi
Created December 12, 2013 16:14
Show Gist options
  • Save plioi/7930624 to your computer and use it in GitHub Desktop.
Save plioi/7930624 to your computer and use it in GitHub Desktop.
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public class SkipAttribute : Attribute
{
public string ExpirationDate { get; set; }
public bool HasExpired
{
get
{
DateTime expirationDate;
return DateTime.TryParse(ExpirationDate, out expirationDate)
&& DateTime.Now > expirationDate;
}
}
}
public class CustomConvention : Convention
{
public CustomConvention()
{
Classes
.NameEndsWith("Tests");
Methods
.Where(method => method.IsVoid());
CaseExecution
.Skip(@case => {
if (@case.Method.HasOrInherits<SkipAttribute>()) {
var skipAttribute = @case.Method.GetCustomAttributes<SkipAttribute>(true).Single();
return !skipAttribute.HasExpired;
}
return false;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment