You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[IBM DB2](https://www.ibm.com/db2), is a relational database engine developed by IBM. The following example provides .NET developers with a starting point to use a IBM DB2 instance in the [xUnit][xunit] tests.
3
+
[IBM DB2](https://www.ibm.com/db2) is a relational database engine developed by IBM.
4
4
5
-
The following example (for windows) uses the following NuGet packages:
5
+
Add the following dependency to your project file:
6
6
7
-
```console title="Install the NuGet dependencies"
7
+
```shell title="NuGet"
8
8
dotnet add package Testcontainers.Db2
9
-
dotnet add package Net.IBM.Data.Db2
10
-
dotnet add package xunit
11
9
```
12
10
13
-
Please note: For linux there are currently some hurdles and the package Net.IBM.Data.Db2-lnx has to be used with the following environment variables being set:
11
+
!!! warning
14
12
15
-
- LD_LIBRARY_PATH
16
-
- PATH
17
-
- DB2_CLI_DRIVER_INSTALL_PATH
13
+
The Linux client dependency, [Net.IBM.Data.Db2-lnx](https://www.nuget.org/packages/Net.IBM.Data.Db2-lnx), requires additional configurations. We use the [Testcontainers.Db2.Tests.targets](tests/Testcontainers.Db2.Tests/Testcontainers.Db2.Tests.targets) file to configure the environment variables: `LD_LIBRARY_PATH`, `PATH`, `DB2_CLI_DRIVER_INSTALL_PATH`, at runtime.
18
14
19
-
One way to achieve this within a test project is to extend the .csproj with a task that writes a .runsettings file. An example is given below:
IDEs and editors may also require the following packages to run tests: `xunit.runner.visualstudio` and `Microsoft.NET.Test.Sdk`.
27
-
28
-
Copy and paste the following code into a new `.cs` test file within an existing test project.
15
+
You can start an DB2 container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method.
Once Testcontainers creates a server instance, developers may use the connection string with any of the popular data-access technologies found in the .NET Ecosystem. Some of these libraries include [Entity Framework Core](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore), [Dapper](https://www.nuget.org/packages/Dapper), and [NHibernate](https://www.nuget.org/packages/NHibernate). At which point, developers can execute database migrations and SQL scripts.
29
+
To execute the tests, use the command `dotnet test` from a terminal.
/// When <paramref name="acceptLicenseAgreement" /> is set to <c>true</c>, the Db2 <see href="www.ibm.com/terms/?id=L-SNMD-UVTL8R">license</see> is accepted.
50
+
/// </remarks>
51
+
/// <param name="acceptLicenseAgreement">A boolean value indicating whether the Db2 license agreement is accepted.</param>
52
+
/// <returns>A configured instance of <see cref="Db2Builder" />.</returns>
0 commit comments