Skip to content

Commit

Permalink
#26 REST API - BankAccountController
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinajemuovic committed Jun 18, 2022
1 parent 3634cc1 commit 67f18d9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Optivem.Kata.Banking.Web.Controllers
{
[ApiController]
[Route("[controller]")]
[Route("weather")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

Expand Down
1 change: 1 addition & 0 deletions src/Optivem.Kata.Banking.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
app.MapControllers();

app.Run();
public partial class Program { }
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="TngTech.ArchUnitNET" Version="0.10.1" />
Expand All @@ -34,6 +35,7 @@
<ProjectReference Include="..\..\src\Optivem.Kata.Banking.Core\Optivem.Kata.Banking.Core.csproj" />
<ProjectReference Include="..\..\src\Optivem.Kata.Banking.Infrastructure.Fake\Optivem.Kata.Banking.Infrastructure.Fake.csproj" />
<ProjectReference Include="..\..\src\Optivem.Kata.Banking.Infrastructure\Optivem.Kata.Banking.Infrastructure.csproj" />
<ProjectReference Include="..\..\src\Optivem.Kata.Banking.Web\Optivem.Kata.Banking.Web.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,14 +1,61 @@
using System;
using Microsoft.AspNetCore.Mvc.Testing;
using Newtonsoft.Json;
using Optivem.Kata.Banking.Test.Common.Builders.RequestBuilders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Optivem.Kata.Banking.Test.System
{
public class BankAccountControllerSystemTest
public class BankAccountControllerSystemTest : IDisposable
{
private readonly HttpClient _client;

public BankAccountControllerSystemTest()
{
var application = new WebApplicationFactory<Program>()
.WithWebHostBuilder(builder =>
{
// TODO: VC: Configure
});

_client = application.CreateClient();
}

public void Dispose()
{
_client.Dispose();
}


[Fact]
public async Task Nothing()
{
var response = await _client.GetAsync("weather");

response.EnsureSuccessStatusCode();

}

[Fact(Skip = "TODO: In progress")]
public async Task Should_open_bank_account_given_valid_request()
{
var url = "bank-accounts";

var request = OpenAccountRequestBuilder.OpenAccount()
.Build();

var json = JsonConvert.SerializeObject(request);
var body = new StringContent(json, Encoding.UTF8, "application/json");

var response = await _client.PostAsync(url, body);

response.EnsureSuccessStatusCode();
}

}
}

0 comments on commit 67f18d9

Please sign in to comment.