aspnetboilerplate: Problem with IocManager and Test Project
I am using Test project generated by MVC Asp Net Core (Full Standard) template.
My LocalIocManager has more then 1000 registered components.
This property (LocalIocManager) is defined on AbpIntegratedTestBase<TStartupModule>.
I changed UserAppService and i need some another component that is registered on LocalIocManager.
When i run a unit test like:
[Fact]
public async Task GetUsers_Test()
{
var _userAppService = Resolve<IUserAppService>();
// Act
var output = await _userAppService.GetAll(new PagedResultRequestDto
{
MaxResultCount = 20,
SkipCount = 0
});
// Assert
output.Data.Count().ShouldBeGreaterThan(0);
}
The method “Resolve” call resolve form LocalIocManager and _userAppService is created but IocManager property inside _userAppService is created empty, without registered components.
I need that the IocManager property create inside _userAppService be the same as LocalIocManager with all registered components.
Somebody Helps?
Thanks.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 28 (13 by maintainers)
acjh, thanks for your help!
I’ve created a template and checked that Property Injection is working !!. I found the problem in my project, it’s dependency on compiled assembly (Module) using “IocManager.Instance”. Now, with property injection, I can move on with my tests! I’ll refactor to use Constructor Injection as soon as I find the time
A clean fork of aspnetboilerplate/module-zero-core-template would be good.
Do you mean with
Repository.GetAll()
?I suggest using Domain Services:
Show your code.
Yes, this seems to be a good use case of property injection.
I have many entities that implement IUnidadeNegocioScope and i need to extend IQueryable<> with ByScope method that use AbpSession and UserManager to apply a filter on IQuerable.
I have other cases when i need IocManager.Instance but i can solve them if Property Injection work.