fsprojects / Foq

A unit testing framework for F#
http://www.slideshare.net/ptrelford/foq-17062247
Apache License 2.0
79 stars 31 forks source link

Is it possible to first get the abstract and then setup its behaviour? #30

Open voroninp opened 4 years ago

voroninp commented 4 years ago

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:

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
    }
}

Is same achievable with Foq?