Пример #1
0
        public async Task Test_Service_Remove_Game()
        {
            var mock    = new Mock <ILogger <MainService> >();
            var service = new MainService(mock.Object);

            Player player1 = new Player();
            Player player2 = new Player();

            Game game1 = new Game(player1, player2);
            Game game2 = new Game(player1, player2);

            await service.AddGameAsync(game1);

            await service.AddGameAsync(game2);

            var gameList = service.GetGamesAsync().Result.ToList();

            Assert.AreEqual(2, gameList.Count);

            await service.RemoveGameAsync(game2);

            gameList = service.GetGamesAsync().Result.ToList();

            Assert.IsFalse(gameList.Contains(game2));
        }
Пример #2
0
        public async Task Test_Service_Get_Players_Not_In_Game()
        {
            var mock    = new Mock <ILogger <MainService> >();
            var service = new MainService(mock.Object);

            Player player1 = new Player();
            Player player2 = new Player();
            Player player3 = new Player();
            Player player4 = new Player();
            Player player5 = new Player();
            Player player6 = new Player();

            player1.ConnectionId = "1";
            player2.ConnectionId = "2";
            player3.ConnectionId = "3";
            player4.ConnectionId = "4";
            player5.ConnectionId = "5";
            player6.ConnectionId = "6";

            await service.AddPlayerAsync(player1);

            await service.AddPlayerAsync(player2);

            await service.AddPlayerAsync(player3);

            await service.AddPlayerAsync(player4);

            await service.AddPlayerAsync(player5);

            await service.AddPlayerAsync(player6);

            Game game1 = new Game(player1, player2);
            await service.AddGameAsync(game1);

            Game game2 = new Game(player3, player5);
            await service.AddGameAsync(game2);

            var playersNotInGame = service.GetPlayersNotInGameAsync().Result.ToList();

            Assert.AreEqual(2, playersNotInGame.Count);
        }
Пример #3
0
        public async Task Test_Service_Add_Game()
        {
            var mock    = new Mock <ILogger <MainService> >();
            var service = new MainService(mock.Object);

            Player player1 = new Player();
            Player player2 = new Player();

            Game game1 = new Game(player1, player2);
            await service.AddGameAsync(game1);

            var gameList = service.GetGamesAsync().Result.ToList();

            Assert.Contains(game1, gameList);
        }
Пример #4
0
        public async Task Test_Service_Get_Simple_Game_Information_List()
        {
            var mock    = new Mock <ILogger <MainService> >();
            var service = new MainService(mock.Object);

            Player player1 = new Player("Yannicka");
            Player player2 = new Player("Felarius");
            Game   game1   = new Game(player1, player2);
            await service.AddGameAsync(game1);

            var simpleGameInfo = service.GetSimpleGameInformationListAsync().Result;

            Assert.That(() => simpleGameInfo.First().PlayerOne == player1.PlayerName);
            Assert.That(() => simpleGameInfo.First().PlayerTwo == player2.PlayerName);
        }