File tree Expand file tree Collapse file tree
src/DocumentDbTests/MultiTenancy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments