예제 #1
0
        public void CreateGame_ThrowsIfCreateGameFailed()
        {
            var connectionId = "123";

            #region UserHandler
            var userHandler = new Mock <IUserHandler>();

            userHandler.Setup(a => a.GetUser(connectionId))
            .Returns(new User(connectionId, new RegisteredClient()));
            #endregion

            #region ScenarioHandler
            var scenarioHandler = new Mock <IScenarioHandler>();

            scenarioHandler.Setup(a => a.ValidScenario(It.IsAny <string>()))
            .Returns(true);
            #endregion

            var hub = this.GetHub(connectionId,
                                  userHandler: userHandler,
                                  scenarioHandler: scenarioHandler);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.CreateGame("game-name", "scenario");
            });
        }
예제 #2
0
        public void LeaveGame_ThrowsIfUserDoesntExist()
        {
            var connectionId = "123";

            var hub = this.GetHub(connectionId);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.LeaveGame("game-id");
            });
        }
예제 #3
0
        public void CreateGame_ThrowsIfUserDoesntExist()
        {
            var connectionId = "123";

            var hub = this.GetHub(connectionId);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.CreateGame("game-name", "scenario");
            });
        }
예제 #4
0
        public void LeaveGame_ThrowsIfGameDoesntExist()
        {
            var connectionId = "123";

            #region UserHandler
            var userHandler = new Mock <IUserHandler>();

            userHandler.Setup(a => a.GetUser(It.IsAny <string>()))
            .Returns(new User(connectionId, new RegisteredClient()));
            #endregion

            var hub = this.GetHub(connectionId, userHandler: userHandler);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.LeaveGame("game-id");
            });
        }
예제 #5
0
        public void CreateGame_ThrowsIfScenarioDoesntExist()
        {
            var connectionId = "123";

            #region UserHandler
            var userHandler = new Mock <IUserHandler>();

            userHandler.Setup(a => a.GetUser(connectionId))
            .Returns(new User(connectionId, new RegisteredClient()));
            #endregion

            var hub = this.GetHub(connectionId, userHandler: userHandler);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.CreateGame("game-name", "scenario");
            });
        }