public void CreateGame_WhenCreateGameModelIsValid_ShouldAddGameToRepository()
        {
            Game newGame = new Game();
            CreateGameModel createGameModel = new CreateGameModel()
            {
                SessionKey = "100431CZhiZTwwJAh8VTo559HfIyYf8lXyq74Bi2UkBP64ZoLL",
                Password = null,
                Title = "Title",
            };

            mock.Setup(g => g.Users.GetAll()).Returns(new User[]
            {
                new User
                {
                    SessionKey = "100431CZhiZTwwJAh8VTo559HfIyYf8lXyq74Bi2UkBP64ZoLL",
                    Nickname = "Kalinskia",
                    Username = "******",
                },
            }.AsQueryable());
            mock.Setup(u => u.Games.Add(It.IsAny<Game>())).Callback((Game game) => newGame = game);
            GameService gameservice = new GameService(mock.Object);
            gameservice.CreateGame(createGameModel);
            Assert.AreEqual("Title", newGame.Title);
            Assert.IsNull(newGame.Password);
            Assert.AreEqual("Title", newGame.Title);
            Assert.AreEqual("100431CZhiZTwwJAh8VTo559HfIyYf8lXyq74Bi2UkBP64ZoLL", newGame.RedUser.SessionKey);
            Assert.AreEqual("Kalinskia", newGame.RedUser.Nickname);
            Assert.AreEqual("Kalin", newGame.RedUser.Username);
            Assert.AreEqual(9, newGame.MovesLeft);
            Assert.AreEqual("Open", newGame.GameStatus);
            Assert.IsNull(newGame.UserInTurn);
            Assert.IsNull(newGame.Winner);
            Assert.IsNull(newGame.BlueUser);
        }
        public void CreateGame_WhenPasswordIsTooLong_ShouldThrowException()
        {
            GameService gameservice = new GameService(mock.Object);

            CreateGameModel createGameModel = new CreateGameModel()
            {
                SessionKey = "100431CZhiZTwwJAh8VTo559HfIyYf8lXyq74Bi2UkBP64ZoLL",
                Password = "******",
                Title = "Title",
            };
            gameservice.CreateGame(createGameModel);
        }
 public void CreateGame_WhenCreateGameModelIsNull_ShouldThrowException()
 {
     GameService gameservice = new GameService(mock.Object);
     gameservice.CreateGame(null);
 }
 public void CreateGame_WhenSessionKeyIsInvalid_ShouldThrowException()
 {
     GameService gameservice = new GameService(mock.Object);
     CreateGameModel createGameModel = new CreateGameModel()
     {
         SessionKey = "InvalidSessionKey",
         Password = null,
         Title = "Title",
     };
     gameservice.CreateGame(createGameModel);
 }