66using Xunit ;
77
88namespace Auth0Net . DependencyInjection . Tests ;
9-
9+ #pragma warning disable AUTH0_EXPERIMENTAL
1010public class OrganizationScopeFactoryTests
1111{
1212 [ Fact ]
@@ -15,10 +15,9 @@ public void OrganizationScopeFactory_ThrowsForAuthenticationApiClient()
1515 var client = A . Fake < IAuthenticationApiClient > ( ) ;
1616 var accessor = new HttpClientOrganizationAccessor ( ) ;
1717
18- #pragma warning disable AUTH0_EXPERIMENTAL
1918 Assert . Throws < InvalidOperationException > ( ( ) =>
2019 new OrganizationScopeFactory < IAuthenticationApiClient > ( client , accessor ) ) ;
21- #pragma warning restore AUTH0_EXPERIMENTAL
20+
2221 }
2322
2423 [ Fact ]
@@ -27,10 +26,22 @@ public void OrganizationScopeFactory_ThrowsForManagementApiClient()
2726 var client = A . Fake < IManagementApiClient > ( ) ;
2827 var accessor = new HttpClientOrganizationAccessor ( ) ;
2928
30- #pragma warning disable AUTH0_EXPERIMENTAL
3129 Assert . Throws < InvalidOperationException > ( ( ) =>
3230 new OrganizationScopeFactory < IManagementApiClient > ( client , accessor ) ) ;
33- #pragma warning restore AUTH0_EXPERIMENTAL
31+ }
32+
33+ [ Fact ]
34+ public void OrganizationScopeFactory_CreateScope_ThrowsInNestedScope ( )
35+ {
36+ var client = new TestClient ( ) ;
37+ var accessor = new HttpClientOrganizationAccessor ( ) ;
38+
39+ var factory = new OrganizationScopeFactory < TestClient > ( client , accessor ) ;
40+ var scope = factory . CreateScope ( "org-123" ) ;
41+ Assert . Throws < InvalidOperationException > ( ( ) => factory . CreateScope ( "org-123" ) ) ;
42+
43+ scope . Dispose ( ) ;
44+ Assert . Null ( accessor . Organization ) ;
3445 }
3546
3647 [ Fact ]
@@ -39,17 +50,17 @@ public void OrganizationScopeFactory_CreateScope_SetsOrganizationOnAccessorAndEx
3950 var client = new TestClient ( ) ;
4051 var accessor = new HttpClientOrganizationAccessor ( ) ;
4152
42- #pragma warning disable AUTH0_EXPERIMENTAL
4353 var factory = new OrganizationScopeFactory < TestClient > ( client , accessor ) ;
4454 var scope = factory . CreateScope ( "org-123" ) ;
45- #pragma warning restore AUTH0_EXPERIMENTAL
46-
55+
4756 Assert . Equal ( "org-123" , accessor . Organization ) ;
4857 Assert . Same ( client , scope . Client ) ;
4958
5059 scope . Dispose ( ) ;
5160 Assert . Null ( accessor . Organization ) ;
5261 }
5362
63+
64+
5465 private sealed class TestClient { }
5566}
0 commit comments