Add some tests
This commit is contained in:
parent
0c6f227049
commit
cd2ec646fd
3 changed files with 196 additions and 2 deletions
|
|
@ -91,10 +91,47 @@ public class RealmServiceTests : IClassFixture<DbFixture>
|
|||
}
|
||||
|
||||
await using var actContext = _dbFixture.CreateDbContext();
|
||||
RealmService sut = new(actContext, _keyService);
|
||||
// Act
|
||||
RealmService sut = new(actContext, _keyService);
|
||||
var result = await sut.FindBySlug(slug, TestContext.Current.CancellationToken);
|
||||
|
||||
// Verify
|
||||
Assert.Equal(name, result?.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("b0423bba-2411-497b-a5b6-c5adf404b862", true)]
|
||||
[InlineData("65ac9dba-6d43-4fa4-b57f-133ed639fbcb", false)]
|
||||
public async Task FindById(string idString, bool shouldFind)
|
||||
{
|
||||
Guid id = new(idString);
|
||||
await using (var setupContext = _dbFixture.CreateDbContext())
|
||||
{
|
||||
setupContext.Realms.Add(new()
|
||||
{
|
||||
Id = new("b0423bba-2411-497b-a5b6-c5adf404b862"),
|
||||
Slug = "foo",
|
||||
Name = "Foo",
|
||||
});
|
||||
setupContext.Realms.Add(new()
|
||||
{
|
||||
Id = new("d4ffc7d0-7b2c-4f02-82b9-a74610435b0d"),
|
||||
Slug = "bar",
|
||||
Name = "Bar",
|
||||
});
|
||||
|
||||
await setupContext.SaveChangesAsync(TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
await using var actContext = _dbFixture.CreateDbContext();
|
||||
// Act
|
||||
RealmService sut = new(actContext, _keyService);
|
||||
Realm? result = await sut.FindById(id, TestContext.Current.CancellationToken);
|
||||
|
||||
// Verify
|
||||
if (shouldFind)
|
||||
Assert.NotNull(result);
|
||||
else
|
||||
Assert.Null(result);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue