Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Testcontainers.dic
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ azurite
capi
creds
dind
dockerignore
dvcm
enumerables
fmpeg
Expand Down Expand Up @@ -38,4 +39,4 @@ tlsverify
toml
toxiproxy
vstest
weaviate
weaviate
4 changes: 3 additions & 1 deletion Testcontainers.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=toxiproxy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=vstest/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=weaviate/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToUsingDeclaration/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseAwaitUsing/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AssignNullToNotNullAttribute/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleNullReferenceException/@EntryIndexedValue">SUGGESTION</s:String>
</wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion src/Testcontainers/Clients/TestcontainersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssemblyInformationalVersionAttribute>()!.InformationalVersion;
public static readonly string Version = typeof(TestcontainersClient).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;

private static readonly string OSRootDirectory = Path.GetPathRoot(Directory.GetCurrentDirectory());

Expand Down
2 changes: 1 addition & 1 deletion src/Testcontainers/Containers/DockerContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public static TheoryData<Type> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -34,7 +34,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
_tarOutputMemoryStream.Dispose();
_testFile.Directory!.Delete(true);
_testFile.Directory.Delete(true);
}

_disposed = true;
Expand Down Expand Up @@ -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();

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void CommonDirectoryPathExists(CommonDirectoryPath commonDirectoryPath)
public void CommonDirectoryPathNotExists()
{
var callerFilePath = Path.GetPathRoot(Directory.GetCurrentDirectory());
Assert.Throws<DirectoryNotFoundException>(() => CommonDirectoryPath.GetGitDirectory(callerFilePath!));
Assert.Throws<DirectoryNotFoundException>(() => CommonDirectoryPath.GetGitDirectory(callerFilePath));
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -63,41 +62,41 @@ public void GetDockerSocketOverrideReturnsNull()
}
}

private sealed class AuthProviderTestData : List<object[]>
private sealed class AuthProviderTestData : TheoryData<IDockerEndpointAuthenticationProvider, bool>
{
public AuthProviderTestData()
{
var defaultConfiguration = new PropertiesFileConfiguration(Array.Empty<string>());
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<ICustomConfiguration>()), 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<ICustomConfiguration>()), 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<ICustomConfiguration>()), 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<ICustomConfiguration>()), false);
Add(new MTlsEndpointAuthenticationProvider(defaultConfiguration, dockerMTlsConfiguration), true);
Add(new TlsEndpointAuthenticationProvider(defaultConfiguration), false);
Add(new TlsEndpointAuthenticationProvider(dockerTlsConfiguration), true);
Add(new TlsEndpointAuthenticationProvider(Array.Empty<ICustomConfiguration>()), false);
Add(new TlsEndpointAuthenticationProvider(defaultConfiguration, dockerTlsConfiguration), true);
Add(new EnvironmentEndpointAuthenticationProvider(defaultConfiguration), false);
Add(new EnvironmentEndpointAuthenticationProvider(DockerHostConfiguration), true);
Add(new EnvironmentEndpointAuthenticationProvider(Array.Empty<ICustomConfiguration>()), 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<object[]>
private sealed class AuthConfigTestData : TheoryData<IDockerEndpointAuthenticationConfiguration, Uri>
{
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));
}
}
}
Expand Down
Loading