Exemple #1
0
        /// <summary>
        /// Change some information about the match.
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="matchId"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public Match MatchUpdate(Tournament tournament, int matchId, MatchUpdateParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var param = parameters.ToDictionary();

            string url = string.Format("tournaments/{0}/matches/{1}", this.TournamentIdentifier(tournament), matchId);
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Put, param);

            return Deserializer.Match(json);
        }
        public void MatchUpdateScores()
        {
            var ms = this.target.MatchIndex(this.tournamentUnderTest);
            Assert.AreEqual(1, ms.Count());

            var match = ms.First();
            Assert.AreEqual(MatchState.open, match.State);

            const string Score = "3-2,4-1,2-2";
            var parameters = new MatchUpdateParameters { ScoresCsv = Score, WinnerId = this.participant1.Id };

            match = this.target.MatchUpdate(this.tournamentUnderTest, match.Id, parameters);
            Assert.AreEqual(MatchState.complete, match.State);
            Assert.AreEqual(this.participant1.Id, match.WinnerId);
            Assert.AreEqual(this.participant2.Id, match.LoserId);
            Assert.AreEqual(Score, match.ScoresCsv);
        }