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

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

                var raceToAdd = new Race()
                {
                    Name        = "Race",
                    Description = "None"
                };

                context.Races.Add(raceToAdd);
                context.SaveChanges();

                var raceFromDb = service.ById(1);

                Assert.Equal(raceToAdd.Name, raceFromDb.Name);
                Assert.Equal(raceToAdd.Description, raceFromDb.Description);
            }
        }
Ejemplo n.º 2
0
        public void ById_WithNoRaces_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoRaces_DbFor_ById")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new RacesService(context, null);
                Assert.Null(service.ById(1));
            }
        }