File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
src/Components/Components/test Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,33 @@ public MyService(Counter counter)
111111 void IDisposable . Dispose ( ) => Counter . DisposedCount ++ ;
112112 }
113113
114+ [ Fact ]
115+ public async Task DisposeAsync_CallsDispose_WithDisposingTrue ( )
116+ {
117+ var services = new ServiceCollection ( ) ;
118+ services . AddTransient < MyService > ( ) ;
119+ var serviceProvider = services . BuildServiceProvider ( ) ;
120+
121+ var renderer = new TestRenderer ( serviceProvider ) ;
122+ var component = ( ComponentWithDispose ) renderer . InstantiateComponent < ComponentWithDispose > ( ) ;
123+
124+ _ = component . MyService ;
125+ await ( ( IAsyncDisposable ) component ) . DisposeAsync ( ) ;
126+ Assert . True ( component . DisposingParameter ) ;
127+ }
128+
129+ private class ComponentWithDispose : OwningComponentBase < MyService >
130+ {
131+ public MyService MyService => Service ;
132+ public bool ? DisposingParameter { get ; private set ; }
133+
134+ protected override void Dispose ( bool disposing )
135+ {
136+ DisposingParameter = disposing ;
137+ base . Dispose ( disposing ) ;
138+ }
139+ }
140+
114141 private class MyOwningComponent : OwningComponentBase < MyService >
115142 {
116143 public MyService MyService => Service ;
You can’t perform that action at this time.
0 commit comments