Ejemplo n.º 1
0
        public void PreventJoining_GivenGameNotStarted()
        {
            var quizGame = new QuizGame(new Mock <IRepository>().Object, new Mock <ICurrencyGenerator>().Object, new Mock <IAutomatedActionSystem>().Object);

            string displayName = Guid.NewGuid().ToString();
            var    result      = quizGame.AttemptToJoin(new ChatUser {
                DisplayName = displayName
            });

            result.Should().Be(QuizJoinResults.NotJoinTimeResult(displayName));
        }
Ejemplo n.º 2
0
        public void AllowJoining_GivenNewUserDuringJoinWindow()
        {
            var quizGame = new QuizGame(new Mock <IRepository>().Object, new Mock <ICurrencyGenerator>().Object, new Mock <IAutomatedActionSystem>().Object);

            string displayName = Guid.NewGuid().ToString();

            quizGame.StartGame(new Mock <IChatClient>().Object);
            var result = quizGame.AttemptToJoin(new ChatUser {
                DisplayName = displayName
            });

            result.Should().Be(QuizJoinResults.SuccessJoinResult(displayName));
        }
Ejemplo n.º 3
0
        public void PreventJoining_GivenAlreadyCompetingUser()
        {
            var quizGame = new QuizGame(new Mock <IRepository>().Object, new Mock <ICurrencyGenerator>().Object, new Mock <IAutomatedActionSystem>().Object);

            var chatUser = new ChatUser {
                DisplayName = "Brendan"
            };

            quizGame.StartGame(new Mock <IChatClient>().Object);
            quizGame.AttemptToJoin(chatUser);
            var result = quizGame.AttemptToJoin(chatUser);

            result.Should().Be(QuizJoinResults.AlreadyInGameResult(chatUser.DisplayName));
        }
Ejemplo n.º 4
0
        public void PreventJoining_GivenQuestionsBeingAsked()
        {
            var    automatedActionSystem = new FakeActionSystem();
            var    mockRepo    = new Mock <IRepository>();
            var    quizGame    = new QuizGame(mockRepo.Object, new Mock <ICurrencyGenerator>().Object, automatedActionSystem);
            string displayName = Guid.NewGuid().ToString();

            quizGame.StartGame(new Mock <IChatClient>().Object);
            mockRepo.Setup(x => x.List(It.IsAny <DataItemPolicy <QuizQuestion> >()))
            .Returns(new List <QuizQuestion> {
                new QuizQuestion()
            });
            automatedActionSystem.IntervalAction.Invoke(); // run the action, starting the questions

            var result = quizGame.AttemptToJoin(new ChatUser {
                DisplayName = displayName
            });

            result.Should().Be(QuizJoinResults.NotJoinTimeResult(displayName));
        }