Created
January 25, 2016 09:07
-
-
Save patroza/aaa6d287105bd53c5915 to your computer and use it in GitHub Desktop.
A slightly improved SpecsFor class
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
/// <summary> | |
/// A more closed version of the official SpecsFor class, | |
/// with some additional helpers | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
public abstract class SpecsFor<T> : SpecsFor.SpecsFor<T>, IAnd<T> where T : class | |
{ | |
protected abstract override void Given(); | |
protected abstract override void When(); | |
public sealed override void TearDown() => base.TearDown(); | |
protected sealed override void InitializeClassUnderTest() => base.InitializeClassUnderTest(); | |
/// <summary> | |
/// A fluent version of Given, so we can use expression bodies | |
/// </summary> | |
/// <typeparam name="TContext"></typeparam> | |
/// <returns></returns> | |
[UsedImplicitly] | |
protected new IAnd<T> Given<TContext>() where TContext : IContext<T>, new() | |
{ | |
base.Given<TContext>(); | |
return this; | |
} | |
IAnd<T> IAnd<T>.And<TContext>() => Given<TContext>(); | |
} | |
public interface IAnd<T> | |
{ | |
IAnd<T> And<TContext>() where TContext : IContext<T>, new(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment