How I Disable filter MayHaveTenant when i'm using in Unit Test?

50 Views Asked by At

I'm write a unit test to validade a specific rule in a AppServiceFile. However in my Service, there are a filter to disable multi-tenant (AbpDataFilters.MayHaveTenant), but when I call this method by my unit-test the filter is not applied.

I'm expect to filter all entities without multi-tenancy filter.

the part of code: enter image description here

public async Task<PagedResultDto<CarteiraClienteDto>> GetTenantsWithContractsAsync(PagedCarteiraClienteRequestDto input)
 {
     CheckGetAllPermission();

     using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
     {
         var query = CreateFilteredQuery(input);
         var totalCount = query.Count();

         query = ApplyPaging(query, input);

         //Here the filter is applied and return all tenants
         var tenants = await AsyncQueryableExecuter.ToListAsync(query);

         //Here no contract is returned
         var contracts = await _contractsRepository.GetAll().AsNoTracking()
             .ToListAsync();

         //TODO: continue the code
     }

     return null;
 }
0

There are 0 best solutions below