From 5a03e7bc986ce668cf82a93eff48af62e81c92d4 Mon Sep 17 00:00:00 2001 From: Alexander Zeitler Date: Tue, 4 Jun 2024 02:24:25 +0200 Subject: [PATCH] test: throw exception when tenant id is missing for when using database per tenant --- .../using_database_per_tenant.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/MultiTenancyTests/using_database_per_tenant.cs diff --git a/src/MultiTenancyTests/using_database_per_tenant.cs b/src/MultiTenancyTests/using_database_per_tenant.cs new file mode 100644 index 0000000000..7dff75b754 --- /dev/null +++ b/src/MultiTenancyTests/using_database_per_tenant.cs @@ -0,0 +1,37 @@ +using System; +using System.Threading.Tasks; +using Marten; +using Marten.Testing.Harness; +using Shouldly; +using Xunit.Abstractions; + +namespace MultiTenancyTests; + +public class using_database_per_tenant: IAsyncLifetime +{ + private readonly ITestOutputHelper _testOutputHelper; + private DocumentStore _theStore; + + public using_database_per_tenant( + ITestOutputHelper testOutputHelper + ) => _testOutputHelper = testOutputHelper; + + public async Task InitializeAsync() + { + _theStore = DocumentStore.For( + options => + { + options.MultiTenantedWithSingleServer(ConnectionSource.ConnectionString); + } + ); + } + + [Fact] + public async Task should_not_meaning_ful_exception_when_tenant_id_is_missing() + { + Should.Throw(() => _theStore.LightweightSession()); + } + + + public async Task DisposeAsync() => await _theStore.DisposeAsync(); +}