Search code examples
mockingmoqjustmock

JustMock Syntax to Moq


I want to translate from JustMock syntax to MOQ :

JustMock :

Mock<Entities> model = new Mock<Entities>();
Mock.Arrange(() => model.Components).IgnoreInstance().ReturnsCollection(this.FakeComponent());

I try:

model.Setup(x => x.Components).Returns(this.FakeComponent());

but fail, Please help me!


Solution

  • If Components is a just a property, you'll need to use SetupGet:

    model.SetupGet(x => x.Components).Returns(this.FakeComponent());
    

    Setup is only for methods.