Hi All,We have a requirement where we have to use NUnit to write test methods and JustMock for mocking the application. Dep injOur application is exposing WCF services and the unit tests will be written to test the WCF Operations.We are using VS 2013.In our application we are using Dependency injection while calling the Constructor i.e. the parameters to the Constuctor are created
using Dependency injection.Pls refer below
public NetworkService(IDbContextFactory<NetworkDbContext> contextFactory, IEventBus eventBus, HostService hostService, UserManagementService userManagementService)
{
_contextFactory = contextFactory.ThrowIfNull("contextFactory");
_eventBus = eventBus.ThrowIfNull("eventBus");
_hostService = hostService.ThrowIfNull("hostService");
_userManagementService = userManagementService.ThrowIfNull("userManagementService");
}
I tried mocking using Telerik Justmock to create the objects of ContextFactory/EventBus etc but the object create using mocking was of type Proxy of actual object rather than the object itself i.e. Proxy of IEventBus rather than IEventBus.The issue with this is, the _contextFactory object is used to create a context like below
using (var ctx = _contextFactory.Create())
But as the object is of type Proxy(Object) I am unable to create the context ctx in above scenario and hence the testing fails.
Can anyone please help me with the mocking.
Any help will be highly appreciated.
Thanks in advance.
using Dependency injection.Pls refer below
public NetworkService(IDbContextFactory<NetworkDbContext> contextFactory, IEventBus eventBus, HostService hostService, UserManagementService userManagementService)
{
_contextFactory = contextFactory.ThrowIfNull("contextFactory");
_eventBus = eventBus.ThrowIfNull("eventBus");
_hostService = hostService.ThrowIfNull("hostService");
_userManagementService = userManagementService.ThrowIfNull("userManagementService");
}
I tried mocking using Telerik Justmock to create the objects of ContextFactory/EventBus etc but the object create using mocking was of type Proxy of actual object rather than the object itself i.e. Proxy of IEventBus rather than IEventBus.The issue with this is, the _contextFactory object is used to create a context like below
using (var ctx = _contextFactory.Create())
But as the object is of type Proxy(Object) I am unable to create the context ctx in above scenario and hence the testing fails.
Can anyone please help me with the mocking.
Any help will be highly appreciated.
Thanks in advance.