-
Notifications
You must be signed in to change notification settings - Fork 26
Description
on a unit test [TestClass] i try to use Ninject and module fakeiteasy but the fakeiteasy dont respect singleton or current object, always create new (different hashcode) on a HttpServer local unit test calling internal with HttpClient, and creating fake object on [TestMethod] things like MustHaveHappend Always fail but another object created and its called.
[TestInitialize]
kernel <-- fakeiteasy (standarkernel load fakeiteasymodule)
kernel.bind.ToMock().InSingletonScope();
config.DependencyResolver = new NinjectResolver(kernel);
HttpServer _server = new HttpServer(config);
//using Effort too but out of scope here
[TestMethod]
client = new HttpClient(_server);
request = new HttpRequestMessage(); //uri, headers, method, etc
obj = kernel.Get();
A.Call.obj ... DoesNothing(); //try with and without
using(response =client.SendAsync(request).Result)
{
A.Call ... MustHaveHappend <-- fail
}
if i debug and check HashCode when code execute de Controller on the webapi (project on same solution) [run on the same process, same thread i think (checked on Thread window] and on unittest method check hashcode and they are different objects.