Пример #1
0
        public void ById_WithNoDungeons_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoDungeons_Db_ForById")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new DungeonsService(context, null);
                Assert.Null(service.ById(1));
            }
        }
Пример #2
0
        public void ById_WithDungeon_ReturnsDungeon()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_ForById_WithDungeon")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new DungeonsService(context, null);

                var dungeonToAdd = new Dungeon()
                {
                    Name = "Dungeon"
                };

                context.Dungeons.Add(dungeonToAdd);
                context.SaveChanges();

                var dungeonFromDb = service.ById(1);

                Assert.Equal(dungeonToAdd.Name, dungeonFromDb.Name);
            }
        }