You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public interface IQueryModel : IQueryModelImmutable
{
public int Property1 { get; set; }
}
public interface IQueryModelImmutable
{
public int Property1 { get; }
}
Mock<IQueryModel> mock = new Mock<IQueryModel>
{
// CallBase = true // does not affect things, can be commented in/out
};
// mock.Setup(m => m.Property1).Returns(100);
mock.As<IQueryModelImmutable>().Setup(m => m.Property1).Returns(100); // works only if both setups are present
IQueryModelImmutable toTest = mock.Object;
Assert.AreEqual(100, mock.Object.Property1);
Assert.AreEqual(100, toTest.Property1);
Tried different combinations of setting up only one of interfaces and using/ not using CallBase - only working one is when both interfaces get_Property1 is set up explicitly.
The text was updated successfully, but these errors were encountered:
I don't get it. If it' not about CallBase, why is it mentioned everywhere, including in your question title? I suggest you rephrase the whole thing and remove whatever isn't actually related to your issue.
Tried different combinations of setting up only one of interfaces and using/ not using
CallBase
- only working one is when both interfacesget_Property1
is set up explicitly.The text was updated successfully, but these errors were encountered: