Created
January 16, 2013 08:41
-
-
Save ewilde/4545584 to your computer and use it in GitHub Desktop.
Machine.fakes class that enables you to program your tests against an interface, but have the SUT created as a concrete type with dependencies auto faked. #mspec
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
using System.Diagnostics.CodeAnalysis; | |
using global::Machine.Fakes; | |
using global::Machine.Specifications; | |
/// <summary> | |
/// Casts the subject as the supplied <typeparamref name="TInterface"/> but | |
/// creates it using a concrete type and fills in dependencies using the auto faking container. | |
/// </summary> | |
/// <typeparam name="TInterface">The type of the interface.</typeparam> | |
/// <typeparam name="TConcreteType">The type of the concrete type.</typeparam> | |
public class WithConcreteSubject<TConcreteType, TInterface> : WithSubject<TConcreteType> | |
where TInterface : class where TConcreteType : class, TInterface | |
{ | |
public static new TInterface Subject | |
{ | |
get | |
{ | |
return WithSubject<TConcreteType>.Subject; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment