public void UndoScoredTossup() { TossupBonusPhaseState phaseState = new TossupBonusPhaseState(); phaseState.AddBuzz(DefaultBuzz); Assert.IsTrue(phaseState.TryScoreBuzz(-5), "Scoring the first buzz should succeed"); Assert.IsTrue( phaseState.AlreadyBuzzedPlayerIds.Contains(DefaultBuzz.UserId), "Default player not in the list of already buzzed players"); Assert.AreEqual(1, phaseState.Actions.Count, "Unexpected number of buzzes recorded"); ulong secondBuzzPlayerId = DefaultBuzz.UserId + 1; string secondTeamId = $"{DefaultBuzz.TeamId}1"; Buzz incorrectBuzz = new Buzz() { TeamId = secondTeamId, PlayerDisplayName = "Bob", UserId = secondBuzzPlayerId, Timestamp = DateTime.Now + TimeSpan.FromSeconds(1) }; phaseState.AddBuzz(incorrectBuzz); Assert.IsTrue(phaseState.TryScoreBuzz(0), "Scoring the second buzz should succeed"); Assert.IsTrue( phaseState.AlreadyBuzzedPlayerIds.Contains(secondBuzzPlayerId), "Second player not in the list of already buzzed players"); Assert.AreEqual(2, phaseState.Actions.Count, "Unexpected number of buzzes recorded after the second buzz"); phaseState.Undo(out ulong?userId); Assert.AreEqual(secondBuzzPlayerId, userId, "Unexpected userId returned by Undo"); Assert.IsTrue( phaseState.AlreadyScoredTeamIds.Contains(DefaultBuzz.TeamId), "Default player not in the list of already scored teams after the first undo"); Assert.IsFalse( phaseState.AlreadyScoredTeamIds.Contains(secondTeamId), "Second player not in the list of already scored teams after the first undo"); Assert.AreEqual(1, phaseState.Actions.Count, "Unexpected number of buzzes recorded after the first undo"); phaseState.Undo(out userId); Assert.AreEqual(DefaultBuzz.UserId, userId, "Unexpected userId returned by Undo"); Assert.IsFalse( phaseState.AlreadyScoredTeamIds.Contains(DefaultBuzz.TeamId), "Default player not in the list of already scored teams after the second undo"); Assert.AreEqual(0, phaseState.Actions.Count, "Unexpected number of buzzes recorded after the second undo"); }
public void UndoBonusAfterScoringIt() { TossupBonusPhaseState phaseState = CreatePhaseInBonusStage(); Assert.IsTrue(phaseState.TryScoreBonus("0"), "Scoring the bonus should've succeeded"); Assert.AreEqual( TossupBonusPhaseState.DefaultBonusLength, phaseState.BonusScores.Count, "We should have three parts scored"); phaseState.Undo(out ulong?userId); Assert.IsNull(userId, "userId should be null (scoring a bonus)"); Assert.AreEqual(0, phaseState.BonusScores.Count, "Bonus scores should be cleared, but not gone"); Assert.AreEqual(PhaseStage.Bonus, phaseState.CurrentStage, "Unexpected stage after first undo"); Assert.IsTrue( phaseState.AlreadyScoredTeamIds.Contains(DefaultBuzz.TeamId), "Default player not in the list of already scored teams after the second undo"); Assert.AreEqual(1, phaseState.Actions.Count, "Unexpected number of buzzes recorded after the second undo"); phaseState.Undo(out userId); Assert.AreEqual(DefaultBuzz.UserId, userId, "userId should not be null after undoing the bonus score"); Assert.IsNull(phaseState.BonusScores, "Bonus scores should be gone"); Assert.AreEqual(PhaseStage.Tossup, phaseState.CurrentStage, "Unexpected stage after second undo"); }