diff --git a/Testcontainers.dic b/Testcontainers.dic index c6533af68..16a6cc3e4 100644 --- a/Testcontainers.dic +++ b/Testcontainers.dic @@ -4,6 +4,7 @@ azurite capi creds dind +dockerignore dvcm enumerables fmpeg @@ -38,4 +39,4 @@ tlsverify toml toxiproxy vstest -weaviate \ No newline at end of file +weaviate diff --git a/Testcontainers.sln.DotSettings b/Testcontainers.sln.DotSettings index 022e8484b..b2618f033 100644 --- a/Testcontainers.sln.DotSettings +++ b/Testcontainers.sln.DotSettings @@ -48,8 +48,10 @@ True True True + DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW - DO_NOT_SHOW + SUGGESTION + SUGGESTION diff --git a/src/Testcontainers/Clients/TestcontainersClient.cs b/src/Testcontainers/Clients/TestcontainersClient.cs index 2e7f54153..eb1a20086 100644 --- a/src/Testcontainers/Clients/TestcontainersClient.cs +++ b/src/Testcontainers/Clients/TestcontainersClient.cs @@ -30,7 +30,7 @@ internal sealed class TestcontainersClient : ITestcontainersClient public const string TestcontainersReuseHashLabel = TestcontainersLabel + ".reuse-hash"; - public static readonly string Version = typeof(TestcontainersClient).Assembly.GetCustomAttribute()!.InformationalVersion; + public static readonly string Version = typeof(TestcontainersClient).Assembly.GetCustomAttribute().InformationalVersion; private static readonly string OSRootDirectory = Path.GetPathRoot(Directory.GetCurrentDirectory()); diff --git a/src/Testcontainers/Containers/DockerContainer.cs b/src/Testcontainers/Containers/DockerContainer.cs index 1ffe9c91a..2221f2e0d 100644 --- a/src/Testcontainers/Containers/DockerContainer.cs +++ b/src/Testcontainers/Containers/DockerContainer.cs @@ -645,7 +645,7 @@ await _configuration.StartupCallback(this, _configuration, ct) Logger.CompleteReadinessCheck(_container.ID); - StartedTime = DateTime.TryParse(_container.State!.StartedAt, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var startedTime) ? startedTime : DateTime.UtcNow; + StartedTime = DateTime.TryParse(_container.State.StartedAt, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var startedTime) ? startedTime : DateTime.UtcNow; if (_configuration.ConnectionStringProvider != null) { diff --git a/tests/Testcontainers.AspireDashboard.Tests/AspireDashboardContainerTest.cs b/tests/Testcontainers.AspireDashboard.Tests/AspireDashboardContainerTest.cs index b9a69097b..1b0a5b9ac 100644 --- a/tests/Testcontainers.AspireDashboard.Tests/AspireDashboardContainerTest.cs +++ b/tests/Testcontainers.AspireDashboard.Tests/AspireDashboardContainerTest.cs @@ -80,7 +80,7 @@ private async Task ExportAndAssertSpanIngestedAsync(Uri endpoint, OtlpExportProt { using (var activity = activitySource.StartActivity(_spanName)) { - activity!.SetTag("test.key", "test-value"); + activity.SetTag("test.key", "test-value"); } } } diff --git a/tests/Testcontainers.Databases.Tests/DatabasesContainerTest.cs b/tests/Testcontainers.Databases.Tests/DatabasesContainerTest.cs index f4e7d156d..6fd39e00f 100644 --- a/tests/Testcontainers.Databases.Tests/DatabasesContainerTest.cs +++ b/tests/Testcontainers.Databases.Tests/DatabasesContainerTest.cs @@ -39,9 +39,9 @@ public static TheoryData GetContainerImplementations(bool expectDataProvid // TODO: If a module contains multiple container implementations, it would require all container implementations to implement the interface. foreach (var containerType in testAssembly.Value.Where(type => type.IsAssignableTo(typeof(IContainer)))) { - var testAssemblyName = testAssembly.Key.GetName().Name!; + var testAssemblyName = testAssembly.Key.GetName().Name; - var containerTypeAssemblyName = containerType.Assembly.GetName().Name!; + var containerTypeAssemblyName = containerType.Assembly.GetName().Name; // If a module utilizes another one of our modules, do not include the container type // if it does not belong to the actual module. For example, the ServiceBus module diff --git a/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs b/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs index 74200c233..d4bc5962a 100644 --- a/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs +++ b/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs @@ -100,7 +100,7 @@ await certificateOperation.WaitForCompletionAsync(TestContext.Current.Cancellati var response = await certificateClient.DownloadCertificateAsync(certificateName, cancellationToken: TestContext.Current.CancellationToken) .ConfigureAwait(true); - using var certificate = response!.Value; + using var certificate = response.Value; // Then Assert.Equal(subject, certificate.Subject); diff --git a/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs b/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs index 034636644..0e5181a78 100644 --- a/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs +++ b/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs @@ -12,7 +12,7 @@ public abstract class TarOutputMemoryStreamTest : IDisposable protected TarOutputMemoryStreamTest() { - _ = Directory.CreateDirectory(_testFile.Directory!.FullName); + _ = Directory.CreateDirectory(_testFile.Directory.FullName); using var fileStream = _testFile.Open(FileMode.Create, FileAccess.Write, FileShare.ReadWrite); fileStream.WriteByte(13); @@ -34,7 +34,7 @@ protected virtual void Dispose(bool disposing) if (disposing) { _tarOutputMemoryStream.Dispose(); - _testFile.Directory!.Delete(true); + _testFile.Directory.Delete(true); } _disposed = true; @@ -195,12 +195,12 @@ public async Task TestFileExistsInContainer() .WithResourceMapping(_testFile.FullName, targetDirectoryPath1) .WithResourceMapping(_testFile, targetDirectoryPath2) .WithResourceMapping(_testFile, new DirectoryInfo(targetDirectoryPath3)) - .WithResourceMapping(_testFile.Directory!, targetDirectoryPath4) - .WithResourceMapping(_testFile.Directory!, new DirectoryInfo(targetDirectoryPath5)) + .WithResourceMapping(_testFile.Directory, targetDirectoryPath4) + .WithResourceMapping(_testFile.Directory, new DirectoryInfo(targetDirectoryPath5)) .WithResourceMapping(new Uri(_testFileUri), new DirectoryInfo(targetDirectoryPath6)) .WithResourceMapping(new Uri(_testFileUri), targetDirectoryPath7.AsDirectory()) .WithResourceMapping(_testFile.FullName.AsFile(), targetDirectoryPath8.AsDirectory()) - .WithResourceMapping(_testFile.Directory!.FullName.AsDirectory(), targetDirectoryPath9.AsDirectory()) + .WithResourceMapping(_testFile.Directory.FullName.AsDirectory(), targetDirectoryPath9.AsDirectory()) .WithResourceMapping(new Uri(_testFileUri), targetDirectoryPath12) .Build(); @@ -211,7 +211,7 @@ await container.StartAsync(TestContext.Current.CancellationToken) await container.CopyAsync(fileContent, targetFilePath9, ct: TestContext.Current.CancellationToken) .ConfigureAwait(true); - await container.CopyAsync(_testFile.Directory!.FullName, targetDirectoryPath10, ct: TestContext.Current.CancellationToken) + await container.CopyAsync(_testFile.Directory.FullName, targetDirectoryPath10, ct: TestContext.Current.CancellationToken) .ConfigureAwait(true); await container.CopyAsync(_testFile.FullName, targetDirectoryPath11, ct: TestContext.Current.CancellationToken) diff --git a/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs b/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs index fc050dd87..f92f9f3cd 100644 --- a/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs +++ b/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs @@ -60,7 +60,7 @@ await page.GotoAsync(_helloWorldBaseAddress.ToString()) var headingElement = await page.QuerySelectorAsync("h1") .ConfigureAwait(true); - var headingElementText = await headingElement!.InnerTextAsync() + var headingElementText = await headingElement.InnerTextAsync() .ConfigureAwait(true); // Then diff --git a/tests/Testcontainers.Tests/Unit/Builders/CommonDirectoryPathTest.cs b/tests/Testcontainers.Tests/Unit/Builders/CommonDirectoryPathTest.cs index 14e4e5ea7..f1d33f3a2 100644 --- a/tests/Testcontainers.Tests/Unit/Builders/CommonDirectoryPathTest.cs +++ b/tests/Testcontainers.Tests/Unit/Builders/CommonDirectoryPathTest.cs @@ -33,7 +33,7 @@ public void CommonDirectoryPathExists(CommonDirectoryPath commonDirectoryPath) public void CommonDirectoryPathNotExists() { var callerFilePath = Path.GetPathRoot(Directory.GetCurrentDirectory()); - Assert.Throws(() => CommonDirectoryPath.GetGitDirectory(callerFilePath!)); + Assert.Throws(() => CommonDirectoryPath.GetGitDirectory(callerFilePath)); } } } diff --git a/tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs b/tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs index 913ec1dd9..34de32900 100644 --- a/tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs +++ b/tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs @@ -1,7 +1,6 @@ namespace DotNet.Testcontainers.Tests.Unit { using System; - using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using DotNet.Testcontainers.Builders; @@ -63,41 +62,41 @@ public void GetDockerSocketOverrideReturnsNull() } } - private sealed class AuthProviderTestData : List + private sealed class AuthProviderTestData : TheoryData { public AuthProviderTestData() { var defaultConfiguration = new PropertiesFileConfiguration(Array.Empty()); var dockerTlsConfiguration = new PropertiesFileConfiguration("docker.tls=true", "docker.cert.path=" + CertificatesDirectoryPath); var dockerMTlsConfiguration = new PropertiesFileConfiguration("docker.tls.verify=true", "docker.cert.path=" + CertificatesDirectoryPath); - Add(new object[] { new MTlsEndpointAuthenticationProvider(defaultConfiguration), false }); - Add(new object[] { new MTlsEndpointAuthenticationProvider(dockerMTlsConfiguration), true }); - Add(new object[] { new MTlsEndpointAuthenticationProvider(Array.Empty()), false }); - Add(new object[] { new MTlsEndpointAuthenticationProvider(defaultConfiguration, dockerMTlsConfiguration), true }); - Add(new object[] { new TlsEndpointAuthenticationProvider(defaultConfiguration), false }); - Add(new object[] { new TlsEndpointAuthenticationProvider(dockerTlsConfiguration), true }); - Add(new object[] { new TlsEndpointAuthenticationProvider(Array.Empty()), false }); - Add(new object[] { new TlsEndpointAuthenticationProvider(defaultConfiguration, dockerTlsConfiguration), true }); - Add(new object[] { new EnvironmentEndpointAuthenticationProvider(defaultConfiguration), false }); - Add(new object[] { new EnvironmentEndpointAuthenticationProvider(DockerHostConfiguration), true }); - Add(new object[] { new EnvironmentEndpointAuthenticationProvider(Array.Empty()), false }); - Add(new object[] { new EnvironmentEndpointAuthenticationProvider(defaultConfiguration, DockerHostConfiguration), true }); - Add(new object[] { new NpipeEndpointAuthenticationProvider(), RuntimeInformation.IsOSPlatform(OSPlatform.Windows) }); - Add(new object[] { new UnixEndpointAuthenticationProvider(), !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) }); - Add(new object[] { new TestcontainersEndpointAuthenticationProvider(string.Empty), false }); - Add(new object[] { new TestcontainersEndpointAuthenticationProvider("tc.host=" + DockerHost), true }); + Add(new MTlsEndpointAuthenticationProvider(defaultConfiguration), false); + Add(new MTlsEndpointAuthenticationProvider(dockerMTlsConfiguration), true); + Add(new MTlsEndpointAuthenticationProvider(Array.Empty()), false); + Add(new MTlsEndpointAuthenticationProvider(defaultConfiguration, dockerMTlsConfiguration), true); + Add(new TlsEndpointAuthenticationProvider(defaultConfiguration), false); + Add(new TlsEndpointAuthenticationProvider(dockerTlsConfiguration), true); + Add(new TlsEndpointAuthenticationProvider(Array.Empty()), false); + Add(new TlsEndpointAuthenticationProvider(defaultConfiguration, dockerTlsConfiguration), true); + Add(new EnvironmentEndpointAuthenticationProvider(defaultConfiguration), false); + Add(new EnvironmentEndpointAuthenticationProvider(DockerHostConfiguration), true); + Add(new EnvironmentEndpointAuthenticationProvider(Array.Empty()), false); + Add(new EnvironmentEndpointAuthenticationProvider(defaultConfiguration, DockerHostConfiguration), true); + Add(new NpipeEndpointAuthenticationProvider(), RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); + Add(new UnixEndpointAuthenticationProvider(), !RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); + Add(new TestcontainersEndpointAuthenticationProvider(string.Empty), false); + Add(new TestcontainersEndpointAuthenticationProvider("tc.host=" + DockerHost), true); } } - private sealed class AuthConfigTestData : List + private sealed class AuthConfigTestData : TheoryData { public AuthConfigTestData() { - Add(new object[] { new TlsEndpointAuthenticationProvider(DockerTlsHostConfiguration).GetAuthConfig(), new Uri(DockerTlsHost) }); - Add(new object[] { new EnvironmentEndpointAuthenticationProvider(DockerHostConfiguration).GetAuthConfig(), new Uri(DockerHost) }); - Add(new object[] { new NpipeEndpointAuthenticationProvider().GetAuthConfig(), new Uri("npipe://./pipe/docker_engine") }); - Add(new object[] { new UnixEndpointAuthenticationProvider().GetAuthConfig(), new Uri("unix:///var/run/docker.sock") }); - Add(new object[] { new TestcontainersEndpointAuthenticationProvider("tc.host=" + DockerHost).GetAuthConfig(), new Uri(DockerHost) }); + Add(new TlsEndpointAuthenticationProvider(DockerTlsHostConfiguration).GetAuthConfig(), new Uri(DockerTlsHost)); + Add(new EnvironmentEndpointAuthenticationProvider(DockerHostConfiguration).GetAuthConfig(), new Uri(DockerHost)); + Add(new NpipeEndpointAuthenticationProvider().GetAuthConfig(), new Uri("npipe://./pipe/docker_engine")); + Add(new UnixEndpointAuthenticationProvider().GetAuthConfig(), new Uri("unix:///var/run/docker.sock")); + Add(new TestcontainersEndpointAuthenticationProvider("tc.host=" + DockerHost).GetAuthConfig(), new Uri(DockerHost)); } } }