Hi Ohad,
Thanks for your reply. But I am still getting error while executing test case for this. We have code something like :
public interface IFoo
{
int Bar();
}
public class Foo : IFoo
{
public Foo(string screenName)
{
}
public int Bar()
{
return 1;
}
}
public class UnderTest
{
private IFoo foo;
public int UseFoo()
{
using (IKernel kernel = new StandardKernel())
{
kernel.Bind<IFoo>().To<Foo>();
foo = kernel.Get<IFoo>(new ConstructorArgument
("screenName", Screen.DispatchScope));
}
return foo.Bar();
}
}
[TestFixture]
public class Tests
{
[Test]
public void Test()
{
Foo fake = Isolate.Fake.Instance<Foo>();
Isolate.WhenCalled(() => fake.Bar()).WillReturn(5);
Isolate.Swap.NextInstance<Foo>().With(fake);
UnderTest ut = new UnderTest();
var result = ut.UseFoo();
Assert.AreEqual(5, result);
}
}
We have class(Foo) constructor having some parameters. When we are replacing Foo class NextInstance with it fake object getting such error, while testing "System.ArgumentNullException : Cannot be null
Parameter name: root" . Please let us know, why we are getting this. Thanks