Starts in:
2 DAYS
11 HRS
43 MIN
45 SEC
Starts in:
2 D
11 H
43 M
45 S
Open Closed

Error when seeding data to test a module coupled with an app-pro template #4566


User avatar
0
learnabp created
  • ABP Framework version: v7.0.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
  1. I have an app-pro template called "Olympic.Trader"
  2. I then added a module called "Olympic.Trader.Store"

The project structure looks like this

When I use "StoreDataSeedContributor.cs" under "Olympic.Trader.Store.TestBase" project and create the "OrderEfCoreTests.cs" in the "Olympic.Trader.Store.EntityFrameworkCore.Tests" in the modules test folder it throws an error about dependency injection of IdentityManager.

However, it works fine when I use The "TraderTestDataBuilder.cs" in the "Olympic.Trader.TestBase" project

The error I get is as follows when using the StoreDataSeedContributor.cs" under "Olymic.Trader.Store.Testbase" project under the folder "test\Olympic.Trader.Store.Tests" of the module.

Autofac.Core.DependencyResolutionException: An exception was thrown while activating Olympic.Trader.Store.StoreDataSeedContributor. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Olympic.Trader.Store.StoreDataSeedContributor' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.Identity.IdentityUserManager identityUserManager' of constructor 'Void .ctor(Volo.Abp.Domain.Repositories.IRepository2[Olympic.Trader.Store.Orders.Order,System.Guid], Volo.Abp.Domain.Repositories.IRepository2[Olympic.Trader.Store.Products.Product,System.Guid], Volo.Abp.Identity.IdentityUserManager, Volo.Abp.Guids.IGuidGenerator, Olympic.Trader.Store.TestData)'. at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass12_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) --- End of inner exception stack trace --- at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.ScopeSelectionMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType) at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Volo.Abp.Data.DataSeeder.SeedAsync(DataSeedContext context) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Olympic.Trader.Store.StoreTestBaseModule.<>c__DisplayClass2_0.<<SeedTestData>b__0>d.MoveNext() in C:\Training\Olympic\_Practice\Olympic.Trader\modules\Olympic.Trader.Store\test\Olympic.Trader.Store.TestBase\StoreTestBaseModule.cs:line 35 --- End of stack trace from previous location --- at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.<>c__DisplayClass15_0.<Run>b__0(Task t) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func1 action) at Volo.Abp.Threading.AsyncHelper.RunSync(Func`1 action) at Olympic.Trader.Store.StoreTestBaseModule.SeedTestData(ApplicationInitializationContext context) in C:\Training\Olympic_Practice\Olympic.Trader\modules\Olympic.Trader.Store\test\Olympic.Trader.Store.TestBase\StoreTestBaseModule.cs:line 31 at Olympic.Trader.Store.StoreTestBaseModule.OnApplicationInitialization(ApplicationInitializationContext context) in C:\Training\Olympic_Practice\Olympic.Trader\modules\Olympic.Trader.Store\test\Olympic.Trader.Store.TestBase\StoreTestBaseModule.cs:line 26 at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module) at Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context)


7 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This may be related to your project configuration, but I don't know the details, could you share a project that can reproduce the problem with me? shiwei.liang@volosoft.com I will check it out. thanks.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I can run the unit tests without any errors.

    Am I missing something?

  • User Avatar
    0
    learnabp created

    The loading of data is commented out in the StoreDataSeedContributor in the Olympic.Trader.Store.TestBase project

    public async Task SeedAsync(DataSeedContext context)
    {
        /* Instead of returning the Task.CompletedTask, you can insert your test data
         * at this point!
         */
        await CreateSampleDataAsync();
    }
    

    un-comment await CreateSampleDataAsync

    you will get the error about Identity Manager

    can we please do a screen share so i can show you ???

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Because the Olympic.Trader is a module template and it does not reference the identity module.

    You need to install the Volo.Abp.Identity.Pro.EntityFrameworkCore and Volo.Abp.Identity.Pro.Domain to the test project.

    PS: The TestData need to implement the ISingletonDependency interface

  • User Avatar
    0
    learnabp created

    Hi,

    Because the Olympic.Trader is a module template and it does not reference the identity module.

    You need to install the Volo.Abp.Identity.Pro.EntityFrameworkCore and Volo.Abp.Identity.Pro.Domain to the test project.

    PS: The TestData need to implement the ISingletonDependency interface

    I think you mean Olympic.Trader.Store is a module template?

    The Olympic.Trader is an app-pro template

  • User Avatar
    0
    learnabp created

    can you please send me the fixed solution back because i can't get it working still

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    shared

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06