Using fake implementation
public class FakeResult<T> : IResult<T> {
public bool Success {
get { return true; }
}
}
along with adding settings TypeRelay
fixture.Customizations.Add(new TypeRelay(typeof(IResult<>), typeof(FakeResult<>)));
All calls IResult<>will use FakeResult<>one that has Successto return trueregardless of type T.
A complete example to verify that the layout works as intended.
[TestClass]
public class AutoFixtureDefaultGeneric {
[TestMethod]
public void AutoFixture_Should_Create_Generic_With_Default() {
Fixture fixture = new Fixture();
fixture.Customizations.Add(new TypeRelay(typeof(IResult<>), typeof(FakeResult<>)));
var result = fixture.Create<IResult<string>>();
result.Success.Should().BeTrue();
}
}
Nkosi source
share