question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with IocManager and Test Project

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:28 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
vitorlacerdacommented, Sep 15, 2018

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

1reaction
acjhcommented, Sep 10, 2018

A clean fork of aspnetboilerplate/module-zero-core-template would be good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IocManager.Instance in integration tests #10577
IocManager.Instance is fine normally, but in a test project, it doesn't resolve dependencies. IIocManager should be used in my reading, ...
Read more >
Tests project problem #5195 | Support Center - ASP.NET Zero
Hi guys, I ran all tests and almost all failed with the message "Message: Castle.MicroKernel.ComponentNotFoundException : No component for ...
Read more >
c# - IHostingEnvironment for testing
I'm trying to use the unit test project in ABP 2.0.2 and I get the following error when I run the selected test...
Read more >
IoC | Space Wizards Developer Wiki
IoC stands for Inversion of Control. What our IoCManager does is more specifically Dependency Injection. At it's core, Dependency Injection means that ...
Read more >
Dependency Injection | Documentation Center | ABP.IO
So, if we try to inject the IExternalLogger interface, we get an error indicating that no implementation found. If we register both of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found