Open Closed

Regarding accessing tenant id in unit test cases #1228


User avatar
0
ChetanKumbhar created

Hi,

I am trying to access tenant id in unit test case project. Following configurations i have done in to my project.

set tenant id in App setting json of project "TenantId": "**********************************"

after this i have done some configuration in TestBaseModul.cs

Configure<AbpMultiTenancyOptions>(options =>
{
    options.IsEnabled = true;
});

public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
    SeedTestData(context);

    var app = context.GetApplicationBuilder();
    app.UseMultiTenancy();
}

Now i am getting Object referance not set to instance .....exception. I have two question,

  1. Is this correct way to access tenant id in unit test cases if yes, then how should i fixed that exception.
  2. If not then, how should i access tenant id in Unit test cases.

ABP Framework version: v3.0.4 UI type: Angular DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): yes / no Exception message and stack trace: Steps to reproduce the issue:


10 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can refer the unit test of abp framework.

    https://github.com/abpframework/abp/blob/dev/framework/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs#L27 https://github.com/abpframework/abp/blob/dev/framework/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs#L55

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#change-the-current-tenant

  • User Avatar
    0
    ChetanKumbhar created

    hi,

    This is not worked, in my project I have called 2nd api inside main service, When i call that a main service throguh postman or web brawser, i am getting tenant id in 2nd api. but same when i call main service into unit test cases, I am getting tenant id as null. I am trying to get that tenant through Unit test cases.

    can we connect though online session.?

  • User Avatar
    0
    ChetanKumbhar created

    Hi, It's bit of urgen, can we connect through online session for this issue??

  • User Avatar
    0
    ChetanKumbhar created

    Hi,

    Any update ?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi ChetanKumbhar

    Can you share a simple project to reproduce your problem? liming.ma@volosoft.com

  • User Avatar
    0
    ChetanKumbhar created

    Hi,

    I can not share this one because its size & security, instead this can we connect in online session ?. In that session i can explain briefly to you.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I believe that the problem can be seen remotely, but I need a project to understand and solve, can you use a template project to show your problem?

  • User Avatar
    0
    ChetanKumbhar created

    Hi,

    I can show project & what problem i am facing remotely, but creating template project now it bit taking time because we created modules & separated hosts. & this needs to fix on immediate level.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    https://zoom.us/j/95101853668?pwd=QkMwblFMOVdBd1JKUXdQMzNOK2tDQT09

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 19, 2024, 10:33