Sorry if this is really obvious...
I'm trying to understand why calling someMockInstance.Object calls the class constructor.
Here's an example:
public class Foo
{
public Foo()
{
// Init some stuff
}
public virtual string DoSomething()
{
// Blah
}
}
public class BarTest
{
[Fact]
public void SomeMethod()
{
var mockFoo = new Mock<Foo>();
mockFoo.Setup(m => m.DoSomething()).Returns("SomeValue");
// This causes a call to `Foo.Foo()`
var result = new Bar(mockFoo.Object).SomeMethod();
result.Should().Be(true);
}
}
And I guess as importantly, can we avoid it?
Thanks!