Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"></see> class.
 /// </summary>
 /// <param name="outcome"></param>
 /// <param name="gameId"></param>
 /// <param name="moves"></param>
 /// <param name="winningMove"></param>
 public GameResult(ContestOutcome outcome, int gameId, List <IMove> moves, IMove winningMove)
 {
     Outcome     = outcome;
     ContestId   = gameId;
     Moves       = moves;
     WinningMove = winningMove;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"></see> class.
 /// </summary>
 /// <param name="contestId"></param>
 /// <param name="winner"></param>
 /// <param name="score"></param>
 /// <param name="participants"></param>
 /// <param name="outcome"></param>
 public MatchResult(int contestId, IPlayer winner, IScore score, List <IPlayer> participants, ContestOutcome outcome)
 {
     ContestId    = contestId;
     Winner       = winner;
     Score        = score;
     Participants = participants;
     Outcome      = outcome;
 }
Example #3
0
        public void ToString_ContestOutComeWin_ReturnsExpectedStringMessage()
        {
            //Arrange
            Outcome   = ContestOutcome.Win;
            ContestId = 1;
            var expected = "Match<1>: Result\n\n" +
                           "Match Outcome<Win>\n\n" +
                           "Player<James Kibirige>: Score <2>\n" +
                           "Player<Jonita Laidley>: Score <1>\n\n" +
                           "Player<James Kibirige> Is the Winner!!!\n";

            Mock <IPlayer> player1Mock = new Mock <IPlayer>();

            player1Mock.Setup(m => m.Name).Returns("James Kibirige");
            player1Mock.Setup(m => m.Rules);
            player1Mock.Setup(m => m.SelectMove());

            Mock <IPlayer> player2Mock = new Mock <IPlayer>();

            player2Mock.Setup(m => m.Name).Returns("Jonita Laidley");
            player2Mock.Setup(m => m.Rules);
            player2Mock.Setup(m => m.SelectMove());

            Participants = new List <IPlayer>()
            {
                player1Mock.Object,
                player2Mock.Object
            };

            Dictionary <IPlayer, int> scores = new Dictionary <IPlayer, int>()
            {
                { Participants[0], 2 },
                { Participants[1], 1 }
            };

            Score = new Score(scores);

            MatchResult = new MatchResult(ContestId, Participants[0], Score, Participants, Outcome);

            //Act
            var result = MatchResult.ToString();

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result);
        }