DockerTestsFixture.cs 958 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. namespace Microsoft.NET.Build.Containers.IntegrationTests;
  4. public sealed class DockerTestsFixture : IDisposable
  5. {
  6. private readonly SharedTestOutputHelper _diagnosticOutput;
  7. public DockerTestsFixture(IMessageSink messageSink)
  8. {
  9. _diagnosticOutput = new SharedTestOutputHelper(messageSink);
  10. try
  11. {
  12. DockerRegistryManager.StartAndPopulateDockerRegistry(_diagnosticOutput).GetAwaiter().GetResult();
  13. }
  14. catch
  15. {
  16. Dispose();
  17. throw;
  18. }
  19. }
  20. public void Dispose()
  21. {
  22. try
  23. {
  24. DockerRegistryManager.ShutdownDockerRegistry(_diagnosticOutput);
  25. }
  26. catch
  27. {
  28. _diagnosticOutput.WriteLine("Failed to shutdown docker registry, shut down it manually");
  29. }
  30. }
  31. }