Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration testing #6

Open
brettwinters opened this issue Sep 18, 2024 · 1 comment
Open

Integration testing #6

brettwinters opened this issue Sep 18, 2024 · 1 comment

Comments

@brettwinters
Copy link

brettwinters commented Sep 18, 2024

Hi @myquay

How do I mock a service in a tenant container?

For example, suppose:

.AddMultiTenancy...
    .WithTenantedServices((services, tenant) => {
           services.AddSingleton<SomeService>();
    });

Then in my integration tests when I usually want to mock a service, for example:

hostBuilder.ConfigureServices(s => s.AddSingleton<ISomeService>(_ => someServiceMock.Object));

But since it's in its own container which is resolved internally, this does not return someServiceMock but instead the real service.

I was thinking of mocking the MultiTenantServiceProviderFactory but it's internal...

@myquay
Copy link
Owner

myquay commented Sep 24, 2024

Hi @brettwinters,

This is a really good question; I'll need to set aside some time to look into this one for you. I don't have anything more to add at this point but it's on my radar :)

Thanks,
Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants