初步
This commit is contained in:
1 parent
a1f48945e8
commit
ab935480b0
26 files changed
+829
-5
No files matched your search
@@ -0,0 +1,27 @@
|
||||
using ElectionSystem.Api.Infrastructure.Auditing;
|
||||
using ElectionSystem.Api.Infrastructure.Persistence;
|
||||
using ElectionSystem.Api.Modules.Identity.Domain;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ElectionSystem.Api.Tests;
|
||||
|
||||
public sealed class PersistenceModelTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task UserName_must_be_unique()
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<ElectionDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;
|
||||
await using var context = new ElectionDbContext(options);
|
||||
context.Users.Add(new ApplicationUser { UserName = "admin", DisplayName = "Administrator" });
|
||||
await context.SaveChangesAsync();
|
||||
var index = context.Model.FindEntityType(typeof(ApplicationUser))!.GetIndexes().Single(x => x.Properties.Single().Name == nameof(ApplicationUser.UserName));
|
||||
Assert.True(index.IsUnique);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Audit_entry_does_not_contain_vote_content_field()
|
||||
{
|
||||
var properties = typeof(AuditEntry).GetProperties().Select(property => property.Name);
|
||||
Assert.DoesNotContain(properties, property => property.Contains("Vote", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user