Created
December 12, 2013 16:14
-
-
Save plioi/7930624 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[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