コード例 #1
0
        public void All_WithData_ReturnsSameData()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_WithAchievements")
                          .Options;

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

                var achievements = new List <Achievement>
                {
                    new Achievement()
                    {
                        Name = "1", AcquisitionConditions = "1"
                    },
                    new Achievement()
                    {
                        Name = "2", AcquisitionConditions = "2"
                    },
                    new Achievement()
                    {
                        Name = "3", AcquisitionConditions = "3"
                    }
                };

                context.Achievements.AddRange(achievements);
                context.SaveChanges();

                Assert.Equal(3, service.All().Count);
            }
        }
コード例 #2
0
        public void All_WithNoData_ReturnsNoData()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoAchievements_Db")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new AchievementsService(context, null);
                Assert.Equal(0, service.All().Count);
            }
        }