示例#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");
            });
        }