Skip to content

Commit 944eaf2

Browse files
committed
Test verifying that you can load a single tenanted document from a tenanted session or nested session
1 parent bf279df commit 944eaf2

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Linq;
2+
using System.Threading.Tasks;
3+
using Marten.Testing.Documents;
4+
using Marten.Testing.Harness;
5+
using Shouldly;
6+
using Xunit;
7+
8+
namespace DocumentDbTests.MultiTenancy;
9+
10+
public class mixed_single_and_conjoined_tenancy : OneOffConfigurationsContext
11+
{
12+
public mixed_single_and_conjoined_tenancy()
13+
{
14+
StoreOptions(opts =>
15+
{
16+
opts.Schema.For<Target>().SingleTenanted();
17+
opts.Schema.For<User>().MultiTenanted();
18+
});
19+
}
20+
21+
[Fact]
22+
public async Task load_single_tenanted_document_from_tenanted_session()
23+
{
24+
var targets = Target.GenerateRandomData(100).ToArray();
25+
await theStore.BulkInsertDocumentsAsync(targets);
26+
27+
using var session1 = theStore.LightweightSession("blue");
28+
(await session1.LoadAsync<Target>(targets[0].Id)).ShouldNotBeNull();
29+
30+
// Now do nested
31+
var session2 = theSession.ForTenant("green");
32+
(await session2.LoadAsync<Target>(targets[1].Id)).ShouldNotBeNull();
33+
}
34+
}

0 commit comments

Comments
 (0)