11using System ;
2- using AuthService . DataAccess ;
2+ using System . Collections . Generic ;
3+ using AuthService . DataAccess . EF ;
4+ using AuthService . Domain ;
35using FluentAssertions ;
6+ using Microsoft . EntityFrameworkCore ;
47using Microsoft . Extensions . Options ;
58using Moq ;
69using Xunit ;
@@ -11,21 +14,37 @@ namespace AuthService.Test;
1114public class AuthServiceTests
1215{
1316 private readonly Domain . AuthService authService ;
14- private readonly InsuranceAgentsInMemoryDb agentsDb ;
17+ private readonly IInsuranceAgents agentsRepository ;
1518 private readonly AppSettings appSettings ;
1619 private readonly ITestOutputHelper output ;
1720
1821 public AuthServiceTests ( ITestOutputHelper output )
1922 {
2023 this . output = output ;
21- agentsDb = new InsuranceAgentsInMemoryDb ( ) ;
24+
25+ // Setup EF Core in-memory database
26+ var options = new DbContextOptionsBuilder < AuthDbContext > ( )
27+ . UseInMemoryDatabase ( databaseName : Guid . NewGuid ( ) . ToString ( ) )
28+ . Options ;
29+
30+ var dbContext = new AuthDbContext ( options ) ;
31+ agentsRepository = new InsuranceAgentRepository ( dbContext ) ;
32+
33+ // Seed test data
34+ agentsRepository . Add ( new InsuranceAgent ( "jimmy.solid" , "secret" , "static/avatars/jimmy_solid.png" ,
35+ new List < string > { "TRI" , "HSI" , "FAI" , "CAR" } ) ) ;
36+ agentsRepository . Add ( new InsuranceAgent ( "danny.solid" , "secret" , "static/avatars/danny.solid.png" ,
37+ new List < string > { "TRI" , "HSI" , "FAI" , "CAR" } ) ) ;
38+ agentsRepository . Add ( new InsuranceAgent ( "admin" , "admin" , "static/avatars/admin.png" ,
39+ new List < string > { "TRI" , "HSI" , "FAI" , "CAR" } ) ) ;
40+
2241 appSettings = new AppSettings
2342 {
2443 Secret = "ThisIsASecretKeyForJWTTokenGeneration123456789"
2544 } ;
26- var options = Options . Create ( appSettings ) ;
45+ var appSettingsOptions = Options . Create ( appSettings ) ;
2746
28- authService = new Domain . AuthService ( agentsDb , options ) ;
47+ authService = new Domain . AuthService ( agentsRepository , appSettingsOptions ) ;
2948 }
3049
3150 [ Theory ]
0 commit comments