unit-testingaspnetboilerplate

Error "No component for supporting the service Abp.AspNetCore.MultiTenancy.DomainTenantResolveContributor was found" when run test function


I working with Asp.net boilerplate v.5.12.0 The project works fine with Enabling MultiTenancy And now we need to use the unit test function but when I start to run it I get this error for all functions "No component for supporting the service Abp.AspNetCore.MultiTenancy.DomainTenantResolveContributor was found" I know I should add a resolver for it but I don't know how Or even if I think right or not Thanks for help


Solution

  • After a lot of searches, The solution was I need to add this code into PreInitialize() in ProjectNameTestBaseModule

    IocManager.Register<IWebMultiTenancyConfiguration, WebMultiTenancyConfiguration>();
    IocManager.Register<DomainTenantResolveContributor>(DependencyLifeStyle.Transient);
    IocManager.Register<HttpHeaderTenantResolveContributor>(DependencyLifeStyle.Transient);
    IocManager.Register<HttpCookieTenantResolveContributor>(DependencyLifeStyle.Transient);