I am trying to get Autofixture to setup and create me an anonymous of an interface. I am using the AutoMoqCustomization, but I keep getting an error.
My code is
var configuration = fixture.CreateAnonymous<Mock<IConfiguration>>();
Mock.Get(configuration).SetupAllProperties();
It actually errors on the SetupAllProperties
with
System.ArgumentException : Object instance was not created by Moq. Parameter name: mocked
Anyone know what I am doing wrong?
You're trying to get a
Mock<IConfiguration>
from aMock<IConfiguration>
instance, which is hardly necessary. Just use