Prerequisites
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- What is your product version? 8.9.1
- What is your product type (Angular or MVC)? Angular
- What is product framework type (.net framework or .net core)? Net Core
I am trying to do an Integration Unit Tes, but it is not possible because in some places of the codes use IocManager.Instance.
For example.
In this case the container is null, and it cannot resolve the dependency injection for some services.
Could you please validate if it is ok, or I would need to change something?
3 Answer(s)
-
0
If your test inherits AppTestBase or AbpIntegratedTestBase you can use
Resolve<T>. Just like https://github.com/aspnetzero/aspnet-zero-core/blob/7ccc77e1c574eff37e0e7a30b774caa2f1c367a6/aspnet-core/test/MyCompanyName.AbpZeroTemplate.Tests/MultiTenancy/TenantAppService_Tests.cs#L25Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi,
For a better testable code, we don't suggest using IocManager.Instance, see the bottom of https://aspnetboilerplate.com/Pages/Documents/Dependency-Injection#iiocresolver-iiocmanager-and-iscopediocresolver.
You can try injecting
IIocManagerand use it instead for resolving IBusinessRule.Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
perfect! thanks!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)
