tests(infra,api): refactor to allow further config of TestApi

This commit is contained in:
Stevan Freeborn
2026-03-08 09:15:45 -05:00
parent 870baf7b6c
commit 1a4f7fac8d
12 changed files with 123 additions and 83 deletions
@@ -92,7 +92,7 @@ public class ConnectTests(TestApi testApi) : IntegrationTest(testApi)
[Fact]
public async Task Connect_WhenCalledWithPlaidInstitutionIdThatIsAlreadyConnected_ItShouldReturn409WithProblemDetails()
{
var (user, institution) = await ExecuteAsync(static async (context, ct, sp) =>
var (user, institution) = await Api.ExecuteAsync(static async (context, ct, sp) =>
{
var passwordHasher = sp.GetRequiredService<IPasswordHasher>();
var encryptor = sp.GetRequiredService<IEncryptor>();
@@ -136,7 +136,7 @@ public class ConnectTests(TestApi testApi) : IntegrationTest(testApi)
{
var plaidInstitutionId = "ins_109508";
var (user, publicToken) = await ExecuteAsync(async (context, ct, sp) =>
var (user, publicToken) = await Api.ExecuteAsync(async (context, ct, sp) =>
{
var plaidClient = sp.GetRequiredService<PlaidClient>();
var passwordHasher = sp.GetRequiredService<IPasswordHasher>();
@@ -171,7 +171,7 @@ public class ConnectTests(TestApi testApi) : IntegrationTest(testApi)
response.StatusCode.Should().Be(HttpStatusCode.OK);
var updatedUser = await ExecuteAsync(
var updatedUser = await Api.ExecuteAsync(
async (context, ct) => await context.Set<User>()
.Include(u => u.Institutions)
.ThenInclude(i => i.Metadata)
@@ -39,7 +39,7 @@ public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
[Fact]
public async Task GetAvailable_WhenCalledWithNonExistentInstitutionId_ItShouldReturn404WithProblemDetails()
{
var user = await ExecuteAsync(static async (context, ct, sp) =>
var user = await Api.ExecuteAsync(static async (context, ct, sp) =>
{
var passwordHasher = sp.GetRequiredService<IPasswordHasher>();
var encryptor = sp.GetRequiredService<IEncryptor>();
@@ -65,7 +65,7 @@ public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
[Fact]
public async Task GetAvailable_WhenCalledWithConnectedInstitution_ItShouldReturn200WithAvailableAccounts()
{
var (user, institution, expectedAccounts) = await ExecuteAsync(static async (context, ct, sp) =>
var (user, institution, expectedAccounts) = await Api.ExecuteAsync(static async (context, ct, sp) =>
{
var passwordHasher = sp.GetRequiredService<IPasswordHasher>();
var encryptor = sp.GetRequiredService<IEncryptor>();
@@ -93,10 +93,10 @@ public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
});
var encryptedAccessToken = await encryptor.EncryptAsyncFor(user, exchangeTokenResponse.AccessToken, ct);
var institutionMetadata = PlaidInstitutionMetadata.From(
institutionId,
"Some Bank",
encryptedAccessToken,
exchangeTokenResponse.ItemId
institutionId,
"Some Bank",
encryptedAccessToken,
exchangeTokenResponse.ItemId
);
var institution = Institution.From("Some Bank", institutionMetadata);
@@ -36,7 +36,7 @@ public class GetTests(TestApi testApi) : IntegrationTest(testApi)
[Fact]
public async Task Get_WhenCalledByUser_ItShouldReturn200WithListOfInstitutions()
{
var (user, institution) = await ExecuteAsync(static async (context, ct, sp) =>
var (user, institution) = await Api.ExecuteAsync(static async (context, ct, sp) =>
{
var passwordHasher = sp.GetRequiredService<IPasswordHasher>();
var encryptor = sp.GetRequiredService<IEncryptor>();
@@ -32,7 +32,7 @@ public class LinkTests(TestApi testApi) : IntegrationTest(testApi)
[Fact]
public async Task Link_WhenCalledWithUserWhoExists_ItShouldReturnLinkToken()
{
var user = await ExecuteAsync(static async (context, ct, sp) =>
var user = await Api.ExecuteAsync(static async (context, ct, sp) =>
{
var passwordHasher = sp.GetRequiredService<IPasswordHasher>();
var encryptor = sp.GetRequiredService<IEncryptor>();