Using a fake implementation
public class FakeResult<T> : IResult<T> {
public bool Success {
get { return true; }
}
}
along with adding a TypeRelay customization
fixture.Customizations.Add(new TypeRelay(typeof(IResult<>), typeof(FakeResult<>)));
All calls for IResult<> will use the FakeResult<> which has its Success to return trueno matter what is the type of T.
Full example to test that the mock works as intended.
[TestClass]
public class AutoFixtureDefaultGeneric {
[TestMethod]
public void AutoFixture_Should_Create_Generic_With_Default() {
// Arrange
Fixture fixture = new Fixture();
fixture.Customizations.Add(new TypeRelay(typeof(IResult<>), typeof(FakeResult<>)));
//Act
var result = fixture.Create<IResult<string>>();
//Assert
result.Success.Should().BeTrue();
}
}