Skip to content

Conversation

@shaynevanasperen
Copy link
Contributor

This is some code which demonstrates the problem described in #23

@mwhelan
Copy link
Owner

mwhelan commented Jul 9, 2017

I have now separated out the strategies for creating concrete classes in the TinyMockingContainer, which provides the behaviour required for your test to pass. The IoC container is configured to create concrete classes that aren't registered.

  1. If all the constructor parameters are reference types then I register mocks of them into the container using the mocking framework, as before
  2. If any of the parameters are value types I'm just creating the concrete class with the mocking framework. This means the result is consistent with what you would get if your did your example test natively with a mocking framework, like this:
[Test]
public void TestClass()
{
    string result;
    var sub = Substitute.For<Foo>();
    sub.Bar.Returns("Bar");
    var sut = new Subject();

    result = sut.DoSomethingWithClass(sub);
    result.Should().Be(sub.Bar);
}

I want to make sure this is consistent with what you've done around dependency chains, which I'm not totally clear on after being away from things for awhile.

If it is, we also have to make sure it is consistent in the Autofac Container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants