Example #1
0
        public void GetNonExistantGameStateTest()
        {
            // Arrange
            string             gameID  = "game";
            GameSessionContext context = new GameSessionContext(multiplexerMock.Object);

            // Act
            var result = context.GetGameState(gameID);

            // Assert
            Assert.AreEqual(null, result);
            dbMock.Verify(mock => mock.StringGet(gameID, It.IsAny <CommandFlags>()), Times.Once());
        }
Example #2
0
        public void GetGameStateTest(string gameID, string state)
        {
            // Arrange
            dbMock.Setup(d => d.StringGet(gameID, It.IsAny <CommandFlags>())).Returns(state);
            GameSessionContext context = new GameSessionContext(multiplexerMock.Object);

            // Act
            var result = context.GetGameState(gameID);

            // Assert
            Assert.AreEqual(state, result);
            dbMock.Verify(mock => mock.StringGet(gameID, It.IsAny <CommandFlags>()), Times.Once());
        }
Example #3
0
        public void FailedAddGameStateTest()
        {
            // Arrange
            string     gameID          = "game";
            IGameState state           = new TicTacToeState();
            string     serializedState = JsonConvert.SerializeObject(state);

            dbMock.Setup(d => d.StringSet(gameID, serializedState, null, When.Always, CommandFlags.None)).Returns(false);
            GameSessionContext context = new GameSessionContext(multiplexerMock.Object);

            // Act
            var result = context.AddGameState(gameID, state);

            // Assert
            Assert.AreEqual(null, result);
            dbMock.Verify(mock => mock.StringSet(gameID, serializedState, null, When.Always, CommandFlags.None), Times.Once());
        }