Skip to content

Instantly share code, notes, and snippets.

@ewilde
Created January 16, 2013 08:41
Show Gist options
  • Save ewilde/4545584 to your computer and use it in GitHub Desktop.
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
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