Hi, is it possible to use MockingContainer<T> where T is an abstract class, such as the following:
I've tried the following, the latter works as expected.
I've tried configuring with AutoMockSettings using CallOriginal, but it just seems like NInject always jumps in and fails to find a suitable constructor.
01.
public
abstract
class
SimpleBaseClass
02.
{
03.
private
readonly
IService service;
04.
protected
SimpleBaseClass(IService service)
05.
{
06.
this
.service = service;
07.
}
08.
public
void
CallServiceMethod()
09.
{
10.
this
.service.DoLotsOfThings();
11.
}
12.
}
I've tried the following, the latter works as expected.
01.
[TestMethod]
02.
public
void
AutoMock_AbstractClass_CallsMethod()
03.
{
04.
var container =
new
MockingContainer<SimpleBaseClass>();
05.
//container.Bind<SimpleBaseClass>().ToMock(); // Still fails :(
06.
container.Arrange<IService>(s => s.DoLotsOfThings()).MustBeCalled();
07.
08.
container.Instance.CallServiceMethod();
09.
10.
container.AssertAll();
11.
}
12.
13.
[TestMethod]
14.
public
void
CreateMock_AbstractClass_CallsMethod()
15.
{
16.
var service = Mock.Create<IService>();
17.
var target = Mock.Create<SimpleBaseClass>(Behavior.CallOriginal, service);
18.
19.
target.CallServiceMethod();
20.
21.
service.Assert(s => s.DoLotsOfThings());
22.
}
I've tried configuring with AutoMockSettings using CallOriginal, but it just seems like NInject always jumps in and fails to find a suitable constructor.