mirror of
https://github.com/alex289/CleanArchitecture.git
synced 2025-07-04 04:22:56 +00:00
fix: Seeding test data
This commit is contained in:
parent
2c7748d877
commit
dca566cbf6
@ -7,7 +7,6 @@ using CleanArchitecture.Domain.Enums;
|
|||||||
using CleanArchitecture.Infrastructure.Database;
|
using CleanArchitecture.Infrastructure.Database;
|
||||||
using CleanArchitecture.IntegrationTests.Infrastructure;
|
using CleanArchitecture.IntegrationTests.Infrastructure;
|
||||||
using CleanArchitecture.IntegrationTests.Infrastructure.Auth;
|
using CleanArchitecture.IntegrationTests.Infrastructure.Auth;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@ -40,6 +39,28 @@ public class TestFixtureBase : IAsyncLifetime
|
|||||||
using var scope = Factory.Services.CreateScope();
|
using var scope = Factory.Services.CreateScope();
|
||||||
await using var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
await using var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
|
|
||||||
|
dbContext.Tenants.Add(new Tenant(
|
||||||
|
Ids.Seed.TenantId,
|
||||||
|
"Admin Tenant"));
|
||||||
|
|
||||||
|
dbContext.Users.Add(new User(
|
||||||
|
Ids.Seed.UserId,
|
||||||
|
Ids.Seed.TenantId,
|
||||||
|
"admin@email.com",
|
||||||
|
"Admin",
|
||||||
|
"User",
|
||||||
|
"$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2",
|
||||||
|
UserRole.Admin));
|
||||||
|
|
||||||
|
dbContext.Users.Add(new User(
|
||||||
|
TestAuthenticationOptions.TestUserId,
|
||||||
|
Ids.Seed.TenantId,
|
||||||
|
TestAuthenticationOptions.Email,
|
||||||
|
TestAuthenticationOptions.FirstName,
|
||||||
|
TestAuthenticationOptions.LastName,
|
||||||
|
TestAuthenticationOptions.Password,
|
||||||
|
UserRole.Admin));
|
||||||
|
|
||||||
SeedTestData(dbContext);
|
SeedTestData(dbContext);
|
||||||
await dbContext.SaveChangesAsync();
|
await dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ public sealed class TestAuthenticationOptions : AuthenticationSchemeOptions
|
|||||||
public const string Email = "integration@tests.com";
|
public const string Email = "integration@tests.com";
|
||||||
public const string FirstName = "Integration";
|
public const string FirstName = "Integration";
|
||||||
public const string LastName = "Tests";
|
public const string LastName = "Tests";
|
||||||
|
public const string Password = "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2";
|
||||||
public static Guid TestUserId = new("561e4300-94d6-4c3f-adf5-31c1bdbc64df");
|
public static Guid TestUserId = new("561e4300-94d6-4c3f-adf5-31c1bdbc64df");
|
||||||
|
|
||||||
public ClaimsIdentity Identity { get; } = new(
|
public ClaimsIdentity Identity { get; } = new(
|
||||||
|
Loading…
Reference in New Issue
Block a user