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);
            }
        }
        public void ByName_WithNoProfessions_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoProfessions_ForByName")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new ProfessionsService(context);
                Assert.Null(service.ByName("Non-existing"));
            }
        }
        public void ById_WithNoAchievements_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoAchievements_Db_ForById")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new AchievementsService(context, null);
                Assert.Null(service.ById(1));
            }
        }
        public void Delete_NoData_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoAchievements_Db_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new AchievementsService(context, null);
                Assert.False(service.Delete(2));
            }
        }
Exemplo n.º 5
0
    public Contexts()
    {
        game     = new GameContext();
        gameInfo = new GameInfoContext();
        input    = new InputContext();

        var postConstructors = System.Linq.Enumerable.Where(
            GetType().GetMethods(),
            method => System.Attribute.IsDefined(method, typeof(Entitas.CodeGeneration.Attributes.PostConstructorAttribute))
            );

        foreach (var postConstructor in postConstructors)
        {
            postConstructor.Invoke(this, null);
        }
    }
Exemplo n.º 6
0
        public void AddProfessionToRace_AddsDataProperly()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_ForAddProfToRace")
                          .Options;

            var professionName = "Prof Name";

            using (var context = new GameInfoContext(options))
            {
                var race = new Race()
                {
                    Name        = "race",
                    Description = "none"
                };

                var profession = new Profession()
                {
                    Name         = professionName,
                    ClassRole    = ClassRole.Damage,
                    CombatType   = CombatType.Mage,
                    UsableWeapon = WeaponType.Staff
                };

                context.Races.Add(race);
                context.Professions.Add(profession);
                context.SaveChanges();
            }

            using (var context = new GameInfoContext(options))
            {
                var raceFromDb = context.Races.First();

                var profService = new ProfessionsService(context);
                var service     = new RacesService(context, profService);

                var model = new AddProfessionToRaceInputModel()
                {
                    RaceId         = raceFromDb.Id,
                    ProfessionName = professionName
                };

                Assert.True(service.AddProfessionToRace(model));
            }
        }
        public async Task RemoveRace_WithData_RemovesFromProfession()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "WithRaceInProf_ForRemoveRace")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var profession = new Profession()
                {
                    Name = "ProfWithRace"
                };

                var race = new Race()
                {
                    Name = "RaceWithProf"
                };

                context.Professions.Add(profession);
                context.Races.Add(race);
                await context.SaveChangesAsync();

                var profFromDb = context.Professions.First();
                var raceFromDb = context.Races.First();

                var raceProfession = new RaceProfession()
                {
                    Race         = raceFromDb,
                    RaceId       = raceFromDb.Id,
                    Profession   = profFromDb,
                    ProfessionId = profFromDb.Id
                };

                profFromDb.Races.Add(raceProfession);

                await context.SaveChangesAsync();

                var service = new ProfessionsService(context);
                await service.RemoveRace(profFromDb, raceFromDb);

                Assert.DoesNotContain(raceProfession, profFromDb.Races);
            }
        }
Exemplo n.º 8
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());
            }
        }
        public void ById_WithProfession_ReturnsProfession()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "WithProfession_ForById")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new ProfessionsService(context);

                var professionToAdd = new Profession()
                {
                    Name = "Profession"
                };

                context.Professions.Add(professionToAdd);
                context.SaveChanges();

                var professionFromDb = service.ById(1);

                Assert.Equal(professionToAdd.Name, professionFromDb.Name);
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        public PlayerTierInfo GetPlayerTier(int?PlayerID)
        {
            PlayerTierInfo playerTier = null;

            try
            {
                GameInfoContext gameInfoContext = new GameInfoContext();
                playerTier = gameInfoContext.GetPlayerTier(PlayerID);
                if (playerTier == null)
                {
                    _logger.InfoFormat(playerTier, "No PlayerTier has found.", "GetPlayerTier");
                }
                else
                {
                    _logger.InfoFormat(playerTier, "PlayerTier has found.", "GetPlayerTier");
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(ex.TargetSite, ex.Message, ex.Source, "GetPlayerTier");
            }
            return(playerTier);
        }
Exemplo n.º 12
0
        public PlayerBaseBalance GetPlayerBasePoint(int?PlayerID)
        {
            PlayerBaseBalance playerBaseBalance = null;

            try
            {
                GameInfoContext gameInfoContext = new GameInfoContext();
                playerBaseBalance = gameInfoContext.GetPlayerBasePoint(PlayerID);
                if (playerBaseBalance == null)
                {
                    _logger.InfoFormat(playerBaseBalance, "No PlayerBaseBalance has found.", "GetPlayerBaseBalance");
                }
                else
                {
                    _logger.InfoFormat(playerBaseBalance, "PlayerBaseBalance has found.", "GetPlayerBaseBalance");
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(ex.TargetSite, ex.Message, ex.Source, "GetPlayerBaseBalance");
            }
            return(playerBaseBalance);
        }
Exemplo n.º 13
0
        public List <PokerGameInfo> GetPokerGames(int?FirstRow, int?LastRow, int?TotalRows)
        {
            List <PokerGameInfo> pokerGameList = null;

            try
            {
                GameInfoContext gameInfoContext = new GameInfoContext();
                pokerGameList = gameInfoContext.GetPokerGames(FirstRow, LastRow, TotalRows);
                if (pokerGameList.Count > 0)
                {
                    _logger.InfoFormat(pokerGameList, pokerGameList.Count.ToString() + " pokerGame has found.", "GetPokerGames");
                }
                else
                {
                    _logger.InfoFormat(pokerGameList, "No pokerGame has found.", "GetPokerGames");
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(ex.TargetSite, ex.Message, ex.Source, "GetPokerGames");
            }
            return(pokerGameList);
        }
Exemplo n.º 14
0
        public void ById_WithNPC_ReturnNPC()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_ForById_WithNPC")
                          .Options;

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

                var NPCToAdd = new NPC()
                {
                    Name = "NPC added"
                };

                context.NPCs.Add(NPCToAdd);
                context.SaveChanges();

                var NPCFromDb = service.ById(1);

                Assert.Equal(NPCToAdd.Name, NPCFromDb.Name);
            }
        }
Exemplo n.º 15
0
        public List <PlayerSessionRatings> GetPlayerSessionRatings(int?PlayerID)
        {
            List <PlayerSessionRatings> playerSessionRatings = null;

            try
            {
                GameInfoContext gameInfoContext = new GameInfoContext();
                playerSessionRatings = gameInfoContext.GetPlayerSessionRatings(PlayerID);
                if (playerSessionRatings.Count > 0)
                {
                    _logger.InfoFormat(playerSessionRatings, playerSessionRatings.Count.ToString() + " playerSessionRating has found for PlayerID : " + PlayerID.ToString(), "GetPlayerSessionRatings");
                }
                else
                {
                    _logger.InfoFormat(playerSessionRatings, "No playerSessionRating has found for PlayerID : " + PlayerID.ToString(), "GetPlayerSessionRatings");
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(ex.TargetSite, ex.Message, ex.Source, "GetPlayerSessionRatings");
            }
            return(playerSessionRatings);
        }
Exemplo n.º 16
0
        public void Delete_WithData_DeletesItem()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_WithItems_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                context.Items.Add(new Item()
                {
                    Name = "ToDelete", AcquiredFrom = "None", Usage = "None"
                });
                context.SaveChanges();
            }

            using (var context = new GameInfoContext(options))
            {
                var service = new ItemsService(context);
                var result  = service.Delete(1);

                Assert.True(result);
                Assert.Equal(0, context.Items.Count());
            }
        }
Exemplo n.º 17
0
        public void Delete_WithData_DeletesGuide()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_WithGuides_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                context.Guides.Add(new Guide()
                {
                    Title = "ToDelete", Content = "None"
                });
                context.SaveChanges();
            }

            using (var context = new GameInfoContext(options))
            {
                var service = new GuidesService(context);
                var result  = service.Delete(1);

                Assert.True(result);
                Assert.Equal(0, context.Guides.Count());
            }
        }
Exemplo n.º 18
0
 public DungeonsService(GameInfoContext db, IAchievementsService achievementsService)
 {
     _db = db;
     _achievementsService = achievementsService;
 }
Exemplo n.º 19
0
 public RacesService(GameInfoContext db, IProfessionsService professionsService)
 {
     _db = db;
     _professionsService = professionsService;
 }
Exemplo n.º 20
0
 public CleanupGameDataOnGameEndSystem(GameInfoContext gameInfo, GameContext game) : base(gameInfo)
 {
     _planets = game.GetGroup(GameMatcher.Planet);
     _rockets = game.GetGroup(GameMatcher.Rocket);
     _players = game.GetGroup(GameMatcher.Player);
 }
Exemplo n.º 21
0
 public NPCsService(GameInfoContext db, IItemsService itemsService)
 {
     _db           = db;
     _itemsService = itemsService;
 }
Exemplo n.º 22
0
 public CleanupFlagsSystem(GameInfoContext gameInfo)
 {
     _saveFlagsGroup = gameInfo.GetGroup(GameInfoMatcher.SaveGame);
     _loadFlagsGroup = gameInfo.GetGroup(GameInfoMatcher.LoadGame);
 }
Exemplo n.º 23
0
 public RemoveGameStartOnGameEnd(GameInfoContext gameInfo) : base(gameInfo)
 {
     _gameInfo = gameInfo;
 }
Exemplo n.º 24
0
 public EndGameSystem(GameContext game, GameInfoContext gameInfo) : base(game)
 {
     _game     = game;
     _gameInfo = gameInfo;
     _players  = game.GetGroup(GameMatcher.Player);
 }
Exemplo n.º 25
0
 public GameInfoRepository(GameInfoContext dbContext)
 {
     DbContext = dbContext;
 }
Exemplo n.º 26
0
 public GuidesService(GameInfoContext db)
 {
     _db = db;
 }
Exemplo n.º 27
0
 public ProfessionsService(GameInfoContext db)
 {
     _db = db;
 }
 public GoToMenuOnGameEndSystem(GameInfoContext gameInfo) : base(gameInfo)
 {
     _gameInfo = gameInfo;
 }
Exemplo n.º 29
0
 public HandleEscButtonSystem(GameInfoContext gameInfo)
 {
     _gameInfo = gameInfo;
 }
Exemplo n.º 30
0
 public SetInitialGameStateSystem(GameInfoContext gameInfo)
 {
     _gameInfo = gameInfo;
 }