public void ScoreboardShouldAddNewScoresWhenBoardIsNotFull() { var mockSerializer = new Mock<IScoreSerializer>(); mockSerializer.Setup(s => s.Load()).Returns(this.scores); mockSerializer.Setup(s => s.Save(It.Is<IList<Score>>(l => l.Count == 4))).Verifiable(); this.serializer = mockSerializer.Object; var scoreBoard = new Scoreboard(notifier, serializer, actionsReader); scoreBoard.AddToScoreboard(4, 5); mockSerializer.Verify(); }
public void ScoreboardShouldAddIfScoreIsHighAndBoardIsFull() { this.scores.Add(new Score(1, "Score1", 5)); this.scores.Add(new Score(2, "Score2", 6)); this.scores.Add(new Score(3, "Score3", 7)); this.scores.Add(new Score(1, "Score1", 5)); this.scores.Add(new Score(2, "Score2", 6)); this.scores.Add(new Score(3, "Score3", 7)); this.scores.Add(new Score(3, "Score3", 7)); var mockSerializer = new Mock<IScoreSerializer>(); mockSerializer.Setup(s => s.Load()).Returns(this.scores); mockSerializer.Setup(s => s.Save(It.IsAny<IList<Score>>())); this.serializer = mockSerializer.Object; var scoreBoard = new Scoreboard(notifier, serializer, actionsReader); scoreBoard.AddToScoreboard(2, 5); mockSerializer.Verify(s => s.Save(It.IsAny<IList<Score>>()), Times.Once); }