Closed charlieH1 closed 6 months ago
I did some further digging and think I might have the solution myself but please correct me if wrong or there is a better one
I can fetch the store (which is the endgame of the code anyway) by using the DI which is done by the following steps when using an Ef store:
so now in my code I will call something like:
public TenantManagementController(IMultiTenantContextAccessor<BasicTenantInfo> multiTenantContextAccessor, IMultiTenantStore<BasicTenantInfo> tenantStore,IGeneralHelper generalHelper, ILogger<TenantManagementController> logger) {
_generalHelper = generalHelper;
_contextAccessor = multiTenantContextAccessor;
_tenantStore = tenantStore;
_logger = logger;
}
Looks like a solid approach to me. Cheers.
Hi Guys
Writing some unit tests for some stuff and I need to fake the store (I'm using nSubstitute and no we cant use Moq after the recent shenanigans over there) I was wondering if theres a way I can get the storeInfo but as a interface currently IMutlTenantContext provides it as a class so I cant mock it. I'm going down the route currently of injecting IMultiTenantContextAccessor using the DI and then navigating through MultiTenantContext to StoreInfo. Is thre a different and or better way which will allow me to mock or am scuppered and stuck with what I have. Below is a code snippet of what I'm trying to do and its the line that returnsnull that NSubstitute is unable to act on.