public void FromClassName() { // Given const string message = nameof(this.FromClassName); var log = TestcontainersHostService.GetLogger <ILogger>(); // When log.LogInformation(message); // Then Assert.Contains(message, File.ReadAllText(LogFile)); }
private async Task <ContainerListResponse> Start(string id, CancellationToken ct = default) { using (var cts = new CancellationTokenSource()) { await this.client.AttachAsync(id, this.configuration.OutputConsumer, cts.Token) .ConfigureAwait(false); var startTask = this.client.StartAsync(id, cts.Token); var waitTask = Task.Run(async() => { foreach (var waitStrategy in this.configuration.WaitStrategies) { await WaitStrategy.WaitUntil(() => waitStrategy.Until(this.configuration.Endpoint, id), 100, ct: cts.Token) .ConfigureAwait(false); } }, cts.Token); var tasks = Task.WhenAll(startTask, waitTask); try { await tasks.ConfigureAwait(false); } catch (Exception) { // Get all thrown exceptions in tasks. if (tasks.Exception != null) { TestcontainersHostService.GetLogger <TestcontainersContainer>().LogError(tasks.Exception, "Can not start container {id}", id); throw tasks.Exception; } } finally { cts.Cancel(); } } return(await this.client.GetContainer(id, ct) .ConfigureAwait(false)); }