Skip to content

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

@voroninp

Description

@voroninp

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions