public async Task Function_Can_Handle_Failed_Initialization()
        {
            // Arrange
            void Configure(IServiceCollection services)
            {
                services.AddLogging((builder) => builder.AddXUnit(this));
            }

            using var server = new LambdaTestServer(Configure);
            using var cts    = new CancellationTokenSource(TimeSpan.FromSeconds(2));

            await server.StartAsync(cts.Token);

            var reader = await server.EnqueueAsync(@"{""Values"": null}");

            _ = Task.Run(async() =>
            {
                await reader.WaitToReadAsync(cts.Token);

                if (!cts.IsCancellationRequested)
                {
                    cts.Cancel();
                }
            });

            using var httpClient = server.CreateClient();

            // Act
            await Assert.ThrowsAsync <InvalidOperationException>(
                () => FunctionRunner.RunAsync <MyFailedInitializationHandler>(httpClient, cts.Token));
        }
Esempio n. 2
0
 internal static async Task RunAsync(
     HttpClient httpClient = null,
     CancellationToken cancellationToken = default)
 {
     await FunctionRunner.RunAsync <MyHandler>(httpClient, cancellationToken);
 }