Created
February 28, 2014 17:53
-
-
Save bradwilson/9276064 to your computer and use it in GitHub Desktop.
Using Expression<T> with data theories for better output display in xUnit.net
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
public static IEnumerable<object[]> ExpirationMethods | |
{ | |
get | |
{ | |
return new TheoryDataSet<Expression<Action<Cache>>> | |
{ | |
cache => cache.Clock.UtcNow.Returns(BaseTime + cache.Duration), | |
cache => cache.Expire() | |
}; | |
} | |
} | |
[Theory] | |
[PropertyData("ExpirationMethods")] | |
public async void MyTheory(Expression<Action<Cache>> expireMethod) | |
{ | |
// ... | |
} | |
// Yields: | |
// Test 'MyClass.MyTheory(expireMethod: cache => cache.Expire())' failed: | |
// NSubstitute.Exceptions.ReceivedCallsException : Expected to receive exactly 1 call matching: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment