Skip to content

Commit

Permalink
docs(#647): Add CLI commands to checkout and run example application
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Nov 2, 2022
1 parent 49591a0 commit fabeb9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion examples/WeatherForecast/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Testcontainers for .NET WeatherForecast example

This example builds and ships a Blazor application in a Docker image build, runs a Docker container and executes tests against a running instance of the application. Testcontainers for .NET takes care of the Docker image build and the Docker container that hosts the application. Spin up as much as containers as you like and run your tests heavily in parallel.
This example builds and ships a Blazor application in a Docker image build, runs a Docker container and executes tests against a running instance of the application. Testcontainers for .NET takes care of the Docker image build and the Docker container that hosts the application. Spin up as much as containers as you like and run your tests heavily in parallel. Checkout and run the tests on your machine:

```console
git clone [email protected]:testcontainers/testcontainers-dotnet.git
cd ./testcontainers-dotnet/examples/WeatherForecast/
dotnet build WeatherForecast.sln
dotnet test WeatherForecast.sln
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using DotNet.Testcontainers.Builders;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using WeatherForecast.Entities;
using Xunit;

Expand Down Expand Up @@ -69,7 +70,7 @@ public Web(WeatherForecastContainer weatherForecastContainer)

[Fact]
[Trait("Category", nameof(Web))]
public async Task Get_WeatherForecast_ReturnsSevenDays()
public void Get_WeatherForecast_ReturnsSevenDays()
{
// Given
string ScreenshotFileName() => $"{nameof(Get_WeatherForecast_ReturnsSevenDays)}_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}.png";
Expand All @@ -83,8 +84,8 @@ public async Task Get_WeatherForecast_ReturnsSevenDays()

chrome.FindElement(By.TagName("fluent-button")).Click();

await Task.Delay(TimeSpan.FromSeconds(1))
.ConfigureAwait(false);
var wait = new WebDriverWait(chrome, TimeSpan.FromSeconds(10));
wait.Until(webDriver => 1.Equals(webDriver.FindElements(By.TagName("span")).Count));

chrome.GetScreenshot().SaveAsFile(Path.Combine(CommonDirectoryPath.GetSolutionDirectory().DirectoryPath, ScreenshotFileName()));

Expand Down

0 comments on commit fabeb9d

Please sign in to comment.