Created
July 1, 2014 06:35
-
-
Save moodmosaic/11558c7db2c6bfac971a to your computer and use it in GitHub Desktop.
Related to http://stackoverflow.com/q/24435874
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 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