예제 #1
0
        public async Task GivenSameAnswersShouldGiveFivePointsForEach()
        {
            await GameManager.StartRoundAsync(Game.Id, (async(r, pIds) =>
            {
                var roundAnswersBuilder = new PlayerAnswersBuilder(Game);

                var dustinAnwers = roundAnswersBuilder
                                   .ForPlayer(TestUsers.Dustin)
                                   .AddAnswer("Nome", "Bruno")
                                   .AddAnswer("CEP", "Brasil")
                                   .AddAnswer("FDS", "Breaking bad")
                                   .Build();

                var lucasAnswers = roundAnswersBuilder
                                   .ForPlayer(TestUsers.Lucas)
                                   .AddAnswer("Nome", "Bruno")
                                   .AddAnswer("CEP", "Brasil")
                                   .AddAnswer("FDS", "Breaking bad")
                                   .Build();

                await GameManager.AddRoundAnswersAsync(dustinAnwers);
                await GameManager.AddRoundAnswersAsync(lucasAnswers);

                var roundValidationsBuilder = new PlayerValidationsBuilder(Game);

                var dustinValidations = roundValidationsBuilder
                                        .ForPlayer(TestUsers.Dustin)
                                        .ForTheme("Nome").ValidateAnswers("Bruno")
                                        .ForTheme("CEP").ValidateAnswers("Brasil")
                                        .ForTheme("FDS").ValidateAnswers("Breaking bad")
                                        .Build();

                var lucasValidations = roundValidationsBuilder
                                       .ForPlayer(TestUsers.Lucas)
                                       .ForTheme("Nome").ValidateAnswers("Bruno")
                                       .ForTheme("CEP").ValidateAnswers("Brasil")
                                       .ForTheme("FDS").ValidateAnswers("Breaking bad")
                                       .Build();

                await GameManager.AddRoundValidationsAsync(dustinValidations);
                await GameManager.AddRoundValidationsAsync(lucasValidations);

                await RoundScorer.ProcessRoundPontuationAsync(Game.CurrentRound);
                var roundPontuations = Game.GetScoreboard(Game.CurrentRoundNumber);

                Assert.AreEqual(5, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Dustin, "Nome"));
                Assert.AreEqual(5, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Dustin, "CEP"));
                Assert.AreEqual(5, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Dustin, "FDS"));
                Assert.AreEqual(15, roundPontuations.GetPlayerPontuation(TestUsers.Dustin));

                Assert.AreEqual(5, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Lucas, "Nome"));
                Assert.AreEqual(5, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Lucas, "CEP"));
                Assert.AreEqual(5, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Lucas, "FDS"));
                Assert.AreEqual(15, roundPontuations.GetPlayerPontuation(TestUsers.Lucas));
            }));
        }
예제 #2
0
        public async Task PontuationIsCorrectWhenAllAnswersDisctinct()
        {
            await GameManager.StartRoundAsync(Game.Id, (async(r, pIds) =>
            {
                var roundAnswersBuilder = new PlayerAnswersBuilder(Game);

                var dustinAnwers = roundAnswersBuilder
                                   .ForPlayer(TestUsers.Dustin)
                                   .AddAnswer("Nome", "Bruno")
                                   .AddAnswer("CEP", "Brasil")
                                   .AddAnswer("FDS", "Breaking Bad")
                                   .Build();

                var lucasAnswers = roundAnswersBuilder
                                   .ForPlayer(TestUsers.Lucas)
                                   .AddAnswer("Nome", "Bruna")
                                   .AddAnswer("CEP", "Brasilia")
                                   .AddAnswer("FDS", "Ben 10")
                                   .Build();

                await GameManager.AddRoundAnswersAsync(dustinAnwers);
                await GameManager.AddRoundAnswersAsync(lucasAnswers);

                var roundValidationsBuilder = new PlayerValidationsBuilder(Game);

                var dustinValidations = roundValidationsBuilder
                                        .ForPlayer(TestUsers.Dustin)
                                        .ForTheme("Nome").ValidateAnswers("Bruna")
                                        .ForTheme("CEP").ValidateAnswers("Brasilia")
                                        .ForTheme("FDS").ValidateAnswers("Ben 10")
                                        .Build();

                var lucasValidations = roundValidationsBuilder
                                       .ForPlayer(TestUsers.Lucas)
                                       .ForTheme("Nome").ValidateAnswers("Bruno")
                                       .ForTheme("CEP").ValidateAnswers("Brasil")
                                       .ForTheme("FDS").ValidateAnswers("Breaking bad")
                                       .Build();

                await GameManager.AddRoundValidationsAsync(dustinValidations);
                await GameManager.AddRoundValidationsAsync(lucasValidations);

                await RoundScorer.ProcessRoundPontuationAsync(Game.CurrentRound);
                var roundPontuations = Game.GetScoreboard(Game.CurrentRoundNumber);

                Assert.AreEqual(10, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Dustin, "Nome"));
                Assert.AreEqual(10, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Dustin, "CEP"));
                Assert.AreEqual(10, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Dustin, "FDS"));
                Assert.AreEqual(30, roundPontuations.GetPlayerPontuation(TestUsers.Dustin));

                Assert.AreEqual(10, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Lucas, "Nome"));
                Assert.AreEqual(10, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Lucas, "CEP"));
                Assert.AreEqual(10, roundPontuations.GetPlayerPontuationForTheme(TestUsers.Lucas, "FDS"));
                Assert.AreEqual(30, roundPontuations.GetPlayerPontuation(TestUsers.Lucas));
            }));
        }
예제 #3
0
        public async Task ShouldReturnPontuationsOnlyForPlayersInRound()
        {
            await GameManager.StartRoundAsync(Game.Id, async (r, pIds) =>
            {
                var roundAnswersBuilder = new PlayerAnswersBuilder(Game);

                var dustinAnwers = roundAnswersBuilder
                                   .ForPlayer(TestUsers.Dustin)
                                   .AddAnswer("Nome", "Bruno")
                                   .AddAnswer("CEP", "Brasil")
                                   .AddAnswer("FDS", "Breaking bad")
                                   .Build();

                var lucasAnswers = roundAnswersBuilder
                                   .ForPlayer(TestUsers.Lucas)
                                   .AddAnswer("Nome", "Bruna")
                                   .AddAnswer("CEP", "Brasilia")
                                   .AddAnswer("FDS", "Ben 10")
                                   .Build();

                await GameManager.AddRoundAnswersAsync(dustinAnwers);
                await GameManager.AddRoundAnswersAsync(lucasAnswers);

                var roundValidationsBuilder = new PlayerValidationsBuilder(Game);

                var dustinValidations = roundValidationsBuilder
                                        .ForPlayer(TestUsers.Dustin)
                                        .ForTheme("Nome").ValidateAnswers("Bruna")
                                        .ForTheme("CEP").ValidateAnswers("Brasilia")
                                        .ForTheme("FDS").ValidateAnswers("Ben 10")
                                        .Build();

                var lucasValidations = roundValidationsBuilder
                                       .ForPlayer(TestUsers.Lucas)
                                       .ForTheme("Nome").ValidateAnswers("Bruno")
                                       .ForTheme("CEP").ValidateAnswers("Brasil")
                                       .ForTheme("FDS").ValidateAnswers("Breaking bad")
                                       .Build();

                await GameManager.AddRoundValidationsAsync(dustinValidations);
                await GameManager.AddRoundValidationsAsync(lucasValidations);

                await RoundScorer.ProcessRoundPontuationAsync(Game.CurrentRound);

                var scoreBoard = Game.GetScoreboard(Game.CurrentRoundNumber);

                Assert.True(scoreBoard.Any(p => p.PlayerId == TestUsers.Dustin.Id));
                Assert.True(scoreBoard.Any(p => p.PlayerId == TestUsers.Lucas.Id));
                Assert.False(scoreBoard.Any(p => p.PlayerId == TestUsers.Mike.Id));
                Assert.False(scoreBoard.Any(p => p.PlayerId == TestUsers.Will.Id));
            });
        }