When using Moq framework I usually create mocks and pass mocked objects to constructor of the object under test.
Doing this I avoid repeating part of initialising logic:
public sealed class FooTests
{
private readonly IMock<IBar1> bar1Mock = new Mock<IBar1>();
private readonly IMock<IBar2> bar2Mock = new Mock<IBar2>();
private readonly Foo sut;
public FooTests()
{
sut = new Foo(bar1Mock.Object, bar2Mock.Object);
}
[Fact]
public void Fact1()
{
// setup mocks here
}
}
Description
When using
Moq
framework I usually create mocks and pass mocked objects to constructor of the object under test. Doing this I avoid repeating part of initialising logic:Is same achievable with Foq?