Skip to content

Commit

Permalink
added readme for nuspec mstest and xunit
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotoffia committed Oct 1, 2021
1 parent 503988e commit b7a57e2
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Ductus.FluentDocker.MsTest/Ductus.FluentDocker.MsTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageProjectUrl>https://github.com/mariotoffia/FluentDocker</PackageProjectUrl>
<PackageIconUrl>https://pbs.twimg.com/profile_images/378800000124779041/fbbb494a7eef5f9278c6967b6072ca3e.png</PackageIconUrl>
<PackageId>Ductus.FluentDocker.MsTest</PackageId>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>Docker;Docker-Compose;Docker Compose;Docker-Machine;Docker Machine;Linux;Windows;Mac;Test;NET Core</PackageTags>
<RepositoryType>git</RepositoryType>
Expand All @@ -30,6 +31,10 @@ Documentation: https://github.com/mariotoffia/FluentDocker
<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="GitVersionTask" Version="5.3.7" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="MSTest.TestFramework" Version="1.1.17" />
Expand Down
65 changes: 65 additions & 0 deletions Ductus.FluentDocker.MsTest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# FluentDocker for MsTest

In addition to the standard _FluentDocker_ usage, it adds the ability to use easy testing with containers via MsTest.

For example, fire up a Postgres container inside the test could look like this

```cs
[TestClass]
public class PostgresMsTests : PostgresTestBase
{
[TestMethod]
public void Test()
{
// We now have a running Postgres
// and a valid connection string to use.
}
}
```

This library enables `docker` and `docker-compose` interactions using a _Fluent API_. It is supported on Linux, Windows and Mac. It also has support for the legacy `docker-machine` interactions.

**Have a look at the [project site](https://github.com/mariotoffia/FluentDocker) for more information.**

**Sample Fluent API usage**
```cs
using (
var container =
new Builder().UseContainer()
.UseImage("kiasaki/alpine-postgres")
.ExposePort(5432)
.WithEnvironment("POSTGRES_PASSWORD=mysecretpassword")
.WaitForPort("5432/tcp", 30000 /*30s*/)
.Build()
.Start())
{
var config = container.GetConfiguration(true);
Assert.AreEqual(ServiceRunningState.Running, config.State.ToServiceState());
}
```
The following snippet fires up Postgres and waits for it to be ready. It uses docker-compose file to perform the task.
```cs
var file = Path.Combine(Directory.GetCurrentDirectory(),
(TemplateString) "Resources/ComposeTests/WordPress/docker-compose.yml");

// @formatter:off
using (var svc = new Builder()
.UseContainer()
.UseCompose()
.FromFile(file)
.RemoveOrphans()
.WaitForHttp("wordpress", "http://localhost:8000/wp-admin/install.php")
.Build().Start())
// @formatter:on
{
// We now have a running WordPress with a MySql database
var installPage = await "http://localhost:8000/wp-admin/install.php".Wget();

Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
Assert.AreEqual(1, svc.Hosts.Count); // The host used by compose
Assert.AreEqual(2, svc.Containers.Count); // We can access each individual container
Assert.AreEqual(2, svc.Images.Count); // And the images used.
}
```

👀 It has tons of features, including a low-level command style, services and finally, the Fluent API on top of it.
5 changes: 5 additions & 0 deletions Ductus.FluentDocker.XUnit/Ductus.FluentDocker.XUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageProjectUrl>https://github.com/mariotoffia/FluentDocker</PackageProjectUrl>
<PackageIconUrl>https://pbs.twimg.com/profile_images/378800000124779041/fbbb494a7eef5f9278c6967b6072ca3e.png</PackageIconUrl>
<PackageId>Ductus.FluentDocker.XUnit</PackageId>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>Docker;Docker-Compose;Docker Compose;Docker-Machine;Docker Machine;Linux;Windows;Mac;Test;NET Core</PackageTags>
<RepositoryType>git</RepositoryType>
Expand All @@ -29,6 +30,10 @@
<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="GitVersionTask" Version="5.3.7" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Ductus.FluentDocker\Ductus.FluentDocker.csproj" />
Expand Down
62 changes: 62 additions & 0 deletions Ductus.FluentDocker.XUnit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# FluentDocker for XUnit

In addition to the standard _FluentDocker_ usage, it adds the ability to use easy testing with containers via _XUnit_.

For example, fire up a Postgres container inside the test could look like this

```cs
public class PostgresXUnitTests : IClassFixture<PostgresTestBase>
{
[Fact]
public void Test()
{
// We now have a running Postgres
// and a valid connection string to use.
}
}
```

This library enables `docker` and `docker-compose` interactions using a _Fluent API_. It is supported on Linux, Windows and Mac. It also has support for the legacy `docker-machine` interactions.

**Have a look at the [project site](https://github.com/mariotoffia/FluentDocker) for more information.**

**Sample Fluent API usage**
```cs
using (
var container =
new Builder().UseContainer()
.UseImage("kiasaki/alpine-postgres")
.ExposePort(5432)
.WithEnvironment("POSTGRES_PASSWORD=mysecretpassword")
.WaitForPort("5432/tcp", 30000 /*30s*/)
.Build()
.Start())
{
var config = container.GetConfiguration(true);
Assert.AreEqual(ServiceRunningState.Running, config.State.ToServiceState());
}
```
The following snippet fires up Postgres and waits for it to be ready. It uses docker-compose file to perform the task.
```cs
var file = Path.Combine(Directory.GetCurrentDirectory(),
(TemplateString) "Resources/ComposeTests/WordPress/docker-compose.yml");

using (var svc = new Builder()
.UseContainer()
.UseCompose()
.FromFile(file)
.RemoveOrphans()
.WaitForHttp("wordpress", "http://localhost:8000/wp-admin/install.php")
.Build().Start())
{
// We now have a running WordPress with a MySql database
var installPage = await "http://localhost:8000/wp-admin/install.php".Wget();

Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
Assert.AreEqual(1, svc.Hosts.Count); // The host used by compose
Assert.AreEqual(2, svc.Containers.Count); // We can access each individual container
Assert.AreEqual(2, svc.Images.Count); // And the images used.
}
```

👀 It has tons of features, including a low-level command style, services and finally, the Fluent API on top of it.

0 comments on commit b7a57e2

Please sign in to comment.