public void BeTrue_AfterStarting() { var quizGame = new QuizGame(new Mock <IRepository>().Object, new Mock <ICurrencyGenerator>().Object, new Mock <IAutomatedActionSystem>().Object); quizGame.StartGame(new Mock <IChatClient>().Object); quizGame.IsRunning.Should().BeTrue(); }
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)); }
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)); }
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)); }