change fact to theorie

pull/2/head
Bastien OLLIER 2 years ago
parent 1135c0078d
commit d1a38d2343

@ -6,8 +6,11 @@ namespace TestUnitaire
{ {
public class TestEfLol public class TestEfLol
{ {
[Fact] [Theory]
public async Task TestAddInMemory() [InlineData("zeus","dieu")]
[InlineData("zeus", "dieu")]
[InlineData("zeus", "dieu")]
public async Task TestAddInMemory(String name, String bio)
{ {
// Arrange // Arrange
var connection = new SqliteConnection("DataSource=:memory:"); var connection = new SqliteConnection("DataSource=:memory:");
@ -21,29 +24,23 @@ namespace TestUnitaire
using (var context = new ChampionContext(options)) using (var context = new ChampionContext(options))
{ {
await context.Database.EnsureCreatedAsync(); await context.Database.EnsureCreatedAsync();
var Zeus = new ChampionEntity var Dieu = new ChampionEntity
{
Name = "Zeus",
Bio = "Zeus is the king of the gods."
};
var Poseidon = new ChampionEntity
{ {
Name = "Poseidon", Name = name,
Bio = "Poseidon is the king of the sea." Bio = bio
}; };
ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus"); ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus");
Assert.Null(found); Assert.Null(found);
await context.Champions.AddAsync(Zeus); await context.Champions.AddAsync(Dieu);
await context.Champions.AddAsync(Poseidon);
await context.SaveChangesAsync(); await context.SaveChangesAsync();
found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus"); found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name);
Assert.NotNull(found); Assert.NotNull(found);
Assert.Equal(2, await context.Champions.CountAsync()); Assert.Equal(1, await context.Champions.CountAsync());
Assert.Equal("Zeus", found.Name); Assert.Equal(name, found.Name);
} }
} }

Loading…
Cancel
Save