|
5 | 5 | using Aspire.Hosting.ApplicationModel; |
6 | 6 | using Aspire.Hosting.Testing; |
7 | 7 | using Microsoft.Extensions.DependencyInjection; |
| 8 | +using Microsoft.Extensions.Hosting; |
8 | 9 | using TUnit.Core; |
9 | 10 | using TUnit.Core.Interfaces; |
10 | 11 |
|
@@ -123,6 +124,16 @@ protected virtual void LogProgress(string message) |
123 | 124 | /// </remarks> |
124 | 125 | protected virtual string[] Args => []; |
125 | 126 |
|
| 127 | + /// <summary> |
| 128 | + /// Override to configure the <see cref="DistributedApplicationOptions"/> and |
| 129 | + /// <see cref="Microsoft.Extensions.Hosting.HostApplicationBuilderSettings"/> passed to |
| 130 | + /// <see cref="DistributedApplicationTestingBuilder.CreateAsync{TEntryPoint}(string[], Action{DistributedApplicationOptions, Microsoft.Extensions.Hosting.HostApplicationBuilderSettings}, CancellationToken)"/>. |
| 131 | + /// This callback is invoked during builder creation, before <see cref="ConfigureBuilder"/>. |
| 132 | + /// </summary> |
| 133 | + /// <param name="options">The distributed application options.</param> |
| 134 | + /// <param name="settings">The host application builder settings.</param> |
| 135 | + protected virtual void ConfigureAppHost(DistributedApplicationOptions options, HostApplicationBuilderSettings settings) { } |
| 136 | + |
126 | 137 | /// <summary> |
127 | 138 | /// Override to customize the builder before building the application. |
128 | 139 | /// </summary> |
@@ -201,7 +212,7 @@ public virtual async Task InitializeAsync() |
201 | 212 | var sw = Stopwatch.StartNew(); |
202 | 213 |
|
203 | 214 | LogProgress($"Creating distributed application builder for {typeof(TAppHost).Name}..."); |
204 | | - var builder = await DistributedApplicationTestingBuilder.CreateAsync<TAppHost>(Args); |
| 215 | + var builder = await DistributedApplicationTestingBuilder.CreateAsync<TAppHost>(Args, ConfigureAppHost); |
205 | 216 | ConfigureBuilder(builder); |
206 | 217 | LogProgress($"Builder created in {sw.Elapsed.TotalSeconds:0.0}s"); |
207 | 218 |
|
|
0 commit comments