Test the DbStub a little bit too
continuous-integration/drone/push Build is passing Details

pull/110/head
Alexis Drai 2 years ago
parent d8fead1051
commit 5b4c2469c9

@ -12,15 +12,22 @@ namespace Data.EF
throw new NotImplementedException();
}
public DiceAppDbContextWithStub()
{ }
public DiceAppDbContextWithStub(DbContextOptions<DiceAppDbContext> options)
: base(options)
{ }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<PlayerEntity>().HasData(
new PlayerEntity { ID = Guid.NewGuid(), Name = "Alice" },
new PlayerEntity { ID = Guid.NewGuid(), Name = "Bob" },
new PlayerEntity { ID = Guid.NewGuid(), Name = "Clyde" },
new PlayerEntity { ID = Guid.NewGuid(), Name = "Dahlia" }
new PlayerEntity { ID = Guid.NewGuid(), Name = "Alice" }, // some tests depend on this name
new PlayerEntity { ID = Guid.NewGuid(), Name = "Bob" }, // some tests depend on this name
new PlayerEntity { ID = Guid.NewGuid(), Name = "Clyde" }, // some tests depend on this name
new PlayerEntity { ID = Guid.NewGuid(), Name = "Dahlia" } // some tests depend on this name
);
}
}

@ -33,6 +33,29 @@ namespace Tests.Data_UTs.Players
.Options;
}
[Theory]
[InlineData("Alice")]
[InlineData("Bob")]
[InlineData("Clyde")]
[InlineData("Dahlia")]
public void TestDbStubContainsAll(string name)
{
// Arrange
PlayerDbManager mgr;
// Act
using (DiceAppDbContextWithStub db = new(options))
{
db.Database.EnsureCreated();
mgr = new(db);
// Assert
Assert.True(mgr.IsPresentByName(name));
}
}
[Fact]
public void TestConstructorWhenGivenContextThenConstructs()

Loading…
Cancel
Save