Skip to content

Commit

Permalink
solved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
david-acm committed Dec 7, 2023
2 parents 8cc04fe + bd24614 commit 8f93b06
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Greedy.WebTests/GameApiWebAppFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using DotNet.Testcontainers.Builders;
using Greedy.WebApi.Application;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;

namespace Greedy.WebTests;

public class GameApiWebAppFactory : WebApplicationFactory<GameService> {
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
var environementVariables = new Dictionary<string, string>
{
{ "EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP", "true" },
{ "EVENTSTORE_INSECURE", "true" },
{ "EVENTSTORE_CLUSTER_SIZE", "1" },
{ "EVENTSTORE_EXT_TCP_PORT", "1113" },
{ "EVENTSTORE_HTTP_PORT", "2113" },
{ "EVENTSTORE_ENABLE_EXTERNAL_TCP", "true" },
{ "EVENTSTORE_RUN_PROJECTIONS", "all" },
{ "EVENTSTORE_START_STANDARD_PROJECTIONS", "true" },
{ "PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" },
{ "ASPNETCORE_URLS", "http://+:80" },
{ "DOTNET_RUNNING_IN_CONTAINER", "true" }
};
new ContainerBuilder()
.WithImage("ghcr.io/eventstore/eventstore:21.10.0-alpha-arm64v8")
.WithPortBinding(1113)
.WithPortBinding(2113)
.WithEnvironment(environementVariables)
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(r => r.ForPort(2113)))
.WithAutoRemove(false).Build()
.StartAsync()
.GetAwaiter()
.GetResult();

base.ConfigureWebHost(builder);
}
}
18 changes: 18 additions & 0 deletions Greedy.WebTests/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Net.Http.Json;
using FluentAssertions;

namespace Greedy.WebTests;

public static class HttpClientExtensions {
public static async Task<HttpResponseMessage> PostAndEnsureOkStatusCode(this HttpClient client, string route,
object body)
{
var result = await client.PostAsJsonAsync(route, body);
string content = await result.Content.ReadAsStringAsync();

result.IsSuccessStatusCode.Should().
BeTrue($"Status code returned was: {result.StatusCode}, with reason: {result.ReasonPhrase} {content}");

return result;
}
}

0 comments on commit 8f93b06

Please sign in to comment.