Exemplo n.º 1
0
        public void Delete_NoData_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoDungeons_Db_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new DungeonsService(context, null);
                Assert.False(service.Delete(2));
            }
        }
Exemplo n.º 2
0
        public void Delete_WithData_DeletesDungeon()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_WithDungeon_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                context.Dungeons.Add(new Dungeon()
                {
                    Name = "ToDelete"
                });
                context.SaveChanges();

                var service = new DungeonsService(context, null);
                var result  = service.Delete(1);

                Assert.True(result);
                Assert.Equal(0, context.Dungeons.Count());
            }
        }