Skip to content

Commit a9b8c74

Browse files
authored
Add user existence check to signup integration test (#221)
1 parent e86aeaa commit a9b8c74

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

API.IntegrationTests/AccountTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using System.Net;
22
using System.Text;
33
using System.Text.Json;
4+
using Microsoft.EntityFrameworkCore;
5+
using Microsoft.Extensions.DependencyInjection;
6+
using OpenShock.Common.OpenShockDb;
47

58
namespace OpenShock.API.IntegrationTests;
69

@@ -25,5 +28,12 @@ public async Task CreateAccount_ShouldAdd_NewUserToDatabase()
2528
var content = await response.Content.ReadAsStringAsync();
2629

2730
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);
31+
32+
await using var scope = WebAppFactory.Services.CreateAsyncScope();
33+
var db = scope.ServiceProvider.GetRequiredService<OpenShockContext>();
34+
35+
var user = await db.Users.FirstOrDefaultAsync(u => u.Email == "bob@example.com");
36+
37+
await Assert.That(user is not null).IsTrue();
2838
}
2939
}

0 commit comments

Comments
 (0)