var fake = A.Fake<IInterface>(options => options.Implements<IInteface2>);
A.CallTo(() => ((IInterface2)fake).Property)).ReturnsLazily(call => ((IInterface)call.FakedObject).Property));
ReturnsLazily
, see https://fakeiteasy.readthedocs.io/en/stable/specifying-return-values/#return-values-calculated-at-call-time.)
Hello. I'm trying to create a fake of IOptionsMonitor<T>
like this
var options = A.Fake<IOptionsMonitor<AllowedAppOptions>>();
A.CallTo(() => options.CurrentValue).Returns(new AllowedAppOptions());
As the faked object gets used by accessing CurrentValue
I can see the following in the debugger
Method MetadataMethod(6000045 Microsoft.Extensions.Options.IOptionsMonitor`1::get_CurrentValue,0p) could not be resolved on type MetadataClassType(Castle.Proxies.ObjectProxy_3)
Am I missing something here or is it a general issue?
Microsoft.Extensions.Options
are you using? 3.0.0?
class Program
{
static void Main(string[] args)
{
var monitor = A.Fake<IOptionsMonitor<MyOptions>>();
A.CallTo(() => monitor.CurrentValue).Returns(new MyOptions());
var options = monitor.CurrentValue;
}
}
public class MyOptions
{
public string Foo { get; set; }
public int Bar { get; set; }
}
null
. Not related to FakeItEasy. All my fault. Sorry for making noise here.