Skip to content

Commit

Permalink
Add test and update dependency to fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidoine committed Jul 30, 2017
1 parent 9a9e8cb commit 0a00d37
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Folke.Core/Folke.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Folke.CsTsService" Version="2.0.0.5" />
<PackageReference Include="Folke.Identity.Elm" Version="2.0.0.2" />
<PackageReference Include="Folke.Identity.Elm" Version="2.0.0.3" />
<PackageReference Include="Folke.Identity.Server" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Folke.Core.Tests/Folke.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Folke.Elm.Sqlite" Version="1.4.0.3" />
<PackageReference Include="Folke.Elm.Sqlite" Version="1.4.0.4" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
Expand Down
19 changes: 17 additions & 2 deletions test/Folke.Core.Tests/IntegrationTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Folke.Core.Entities;
using Folke.Elm;
Expand All @@ -10,18 +14,20 @@
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Xunit;

namespace Folke.Core.Tests
{
public class IntegrationTest
{
private readonly HttpClient client;
private readonly TestServer server;

public IntegrationTest()
{
// Arrange
var server = new TestServer(new WebHostBuilder()
server = new TestServer(new WebHostBuilder()
.UseStartup<SampleStartup>());
client = server.CreateClient();
}
Expand All @@ -40,13 +46,22 @@ public async Task CallApiAccountMe_ReturnsNotLogged()
responseString);
}

[Fact]
public async Task LoginAsAdminThenCallApiAccountMe_ReturnsLogged()
{
HttpContent content = new StringContent(JsonConvert.SerializeObject(new { email = "admin@admin.com", password = "mypassword" }), Encoding.UTF8, "application/json");
var responseFromLogin = await client.PutAsync("api/authentication/login", content);
Assert.Equal(HttpStatusCode.OK, responseFromLogin.StatusCode);
}

public class SampleStartup
{
public void ConfigureServices(IServiceCollection services)
{
var temp = Path.GetRandomFileName();
services.AddFolkeCore<SqliteDriver>(options =>
{
options.Elm = elmOptions => elmOptions.ConnectionString = "Data Source=:memory:";
options.Elm = elmOptions => elmOptions.ConnectionString = $"Data Source={temp}.db";
});
}

Expand Down

0 comments on commit 0a00d37

Please sign in to comment.