Skip to content

Instantly share code, notes, and snippets.

@moodmosaic
Created July 1, 2014 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moodmosaic/11558c7db2c6bfac971a to your computer and use it in GitHub Desktop.
Save moodmosaic/11558c7db2c6bfac971a to your computer and use it in GitHub Desktop.
public interface IInterface
{
object MakeIt(object obj);
}
public abstract class AbstractTypeWithNonDefaultConstructor<T>
{
private readonly T property;
protected AbstractTypeWithNonDefaultConstructor(T value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
this.property = value;
}
public T Property
{
get { return this.property; }
}
}
public interface IFoo
{
IInterface Property { get; set; }
}
public interface IBar
{
AbstractTypeWithNonDefaultConstructor<object> Property { get; set; }
}
public class Tests
{
[Fact]
public void InterfaceWithInterfaceProperty()
{
var fixture =
new Fixture().Customize(new AutoNSubstituteCustomization());
var actual = fixture.Create<IFoo>();
Assert.NotNull(actual.Property); // Passes
}
[Fact]
public void InterfaceWithAbstractPropertyWithNonDefaultConstructor()
{
var fixture =
new Fixture().Customize(new AutoNSubstituteCustomization());
var actual = fixture.Create<IBar>();
Assert.NotNull(actual.Property); // Fails, although it should pass.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment