Exemple #1
0
        public void TournamentUpdateType()
        {
            var parameters = new TournamentUpdateParameters {
                Type = TournamentType.RoundRobin
            };
            var updatedTournament = this.target.TournamentUpdate(this.tournamentUnderTest, parameters);

            Assert.AreEqual(updatedTournament.TournamentType, TournamentType.RoundRobin);
        }
Exemple #2
0
        public void TournamentUpdatePrivate()
        {
            var parameters = new TournamentUpdateParameters {
                Private = true
            };

            var updatedTournament = this.target.TournamentUpdate(this.tournamentUnderTest, parameters);

            Assert.IsTrue(updatedTournament.IsPrivate);
        }
Exemple #3
0
        public void TournamentUpdateName()
        {
            var newName    = "TommeTest!" + Utilities.RandomName();
            var parameters = new TournamentUpdateParameters {
                Name = newName
            };

            Thread.Sleep(1500); // Letting time pase, so the updated_at is sure to be different.

            var updatedTournament = this.target.TournamentUpdate(this.tournamentUnderTest, parameters);

            Assert.AreEqual(newName, updatedTournament.Name);
            Assert.IsTrue(updatedTournament.UpdatedAt > this.tournamentUnderTest.UpdatedAt);
        }
        /// <summary>
        /// Update a tournament's attributes.
        /// </summary>
        /// <returns></returns>
        public Tournament TournamentUpdate(Tournament tournament, TournamentUpdateParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            Dictionary <string, dynamic> param = parameters.ToDictionary();

            if (param.Count == 0)
            {
                throw new ArgumentException("You need to change some parameters in order to call update.", "parameters");
            }

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

            return(Deserializer.Tournament(json));
        }
        public void TournamentOperationsInSubdomainControlledByTournamentId()
        {
            var name = "TournamentTest" + Utilities.RandomName();

            var parameter = new TournamentCreateParameters {
                Subdomain = this.subdomain
            };

            this.tournament = this.target.TournamentCreate(name, TournamentType.DoubleElimination, name, parameter);

            const string NewDescription   = "Just another description";
            var          updateParameters = new TournamentUpdateParameters
            {
                Description = NewDescription
            };
            var updatedTournament = this.target.TournamentUpdate(new Tournament {
                Id = this.tournament.Id
            }, updateParameters);

            Assert.AreEqual(NewDescription, updatedTournament.Description);

            // In order to start a tournament do we need some participants.
            this.target.ParticipantCreate(new Tournament {
                Id = this.tournament.Id
            }, new ParticipantCreateParameters {
                Name = Utilities.RandomName()
            });
            this.target.ParticipantCreate(new Tournament {
                Id = this.tournament.Id
            }, new ParticipantCreateParameters {
                Name = Utilities.RandomName()
            });

            var startedTournament = this.target.TournamentStart(new Tournament {
                Id = this.tournament.Id
            });

            Assert.AreEqual(TournamentState.underway, startedTournament.Tournamentstate);
        }
        public void UpdateEveryPropertyInATournament()
        {
            var name = "TournamentTest" + Utilities.RandomName();

            this.tournament = this.target.TournamentCreate(name, TournamentType.Swiss, name);

            Assert.AreEqual(String.Empty, this.tournament.Description);
            Assert.IsFalse(this.tournament.OpenSignup, "Default of open_signup is true");
            Assert.IsFalse(this.tournament.AcceptAttachments, "Default of accept_attachments is true");
            Assert.IsFalse(this.tournament.HideForum, "Default of hide_forum is true");
            Assert.IsFalse(this.tournament.ShowRounds, "Default of show_rounds is true");
            Assert.IsFalse(this.tournament.IsPrivate, "Default of isPrivate is true");
            Assert.IsTrue(this.tournament.NotifyUsersWhenMatchesOpen, "Default of notify_users_when_matches_open is true");
            Assert.IsTrue(this.tournament.NotifyUsersWhenTheTournamentEnds, "Default of notify_users_when_the_tournament_ends is true");
            Assert.IsFalse(this.tournament.SequentialPairings, "Default of sequential_pairings is true");
            Assert.IsNull(this.tournament.SignupCap, "Default of signup_cap is not null");
            Assert.IsFalse(this.tournament.HoldThirdPlaceMatch, "Default of hold_third_place_match is not false");
            Assert.AreEqual(1.0, this.tournament.PtsForMatchWin);
            Assert.AreEqual(0.5, this.tournament.PtsForMatchTie);
            Assert.AreEqual(0.0, this.tournament.PtsForGameWin);
            Assert.AreEqual(0.0, this.tournament.PtsForGameTie);
            Assert.AreEqual(1.0, this.tournament.PtsForBye);
            Assert.AreEqual(0, this.tournament.SwissRounds);
            Assert.IsNull(this.tournament.RankedBy);
            Assert.AreEqual(1.0, this.tournament.RrPtsForMatchWin);
            Assert.AreEqual(0.5, this.tournament.RrPtsForMatchTie);
            Assert.AreEqual(0.0, this.tournament.RrPtsForGameWin);
            Assert.AreEqual(0.0, this.tournament.RrPtsForGameTie);
            Assert.IsNull(this.tournament.StartAt, "Default of started_at is not null");
            Assert.IsTrue(this.tournament.CreatedAt.HasValue);
            Utilities.AssertDateTimeWithin(DateTime.Now, this.tournament.CreatedAt.Value, new TimeSpan(0, 1, 0));
            Assert.IsNull(this.tournament.CheckInDuration);

            // Properties unchanged but still checked.
            Assert.IsTrue(this.tournament.CreatedByApi);
            Assert.IsTrue(this.tournament.AllowParticipantMatchReporting);
            Assert.IsNull(this.tournament.Category);
            Assert.IsNull(this.tournament.CompletedAt);
            Assert.IsFalse(this.tournament.CreditCapped);
            Assert.IsNull(this.tournament.GameId);
            Assert.IsFalse(this.tournament.EnableGroupStage);
            Assert.IsFalse(this.tournament.HideSeeds);
            Assert.AreEqual(1, this.tournament.MaxPredictionsPerUser);
            Assert.AreEqual(0, this.tournament.ParticipantsCount);
            Assert.AreEqual(0, this.tournament.PredictionMethod);
            Assert.IsNull(this.tournament.PredictionsOpenedAt);
            Assert.AreEqual(0, this.tournament.ProgressMeter);
            Assert.IsFalse(this.tournament.QuickAdvance);
            Assert.IsFalse(this.tournament.RequireScoreAgreement);
            Assert.IsNull(this.tournament.StartedCheckingInAt);
            Assert.AreEqual(String.Empty, this.tournament.DescriptionSource);
            Assert.IsNull(this.tournament.Subdomain);
            Assert.AreEqual("http://challonge.com/" + name, this.tournament.FullChallongeUrl);
            Assert.AreEqual("http://images.challonge.com/" + name + ".png", this.tournament.LiveImageUrl);
            Assert.IsNull(this.tournament.SignUpUrl);
            Assert.IsTrue(this.tournament.ReviewBeforeFinalizing);
            Assert.IsFalse(this.tournament.AcceptingPredictions);
            Assert.IsFalse(this.tournament.ParticipantsLocked);
            Assert.IsNull(this.tournament.GameName);
            Assert.IsTrue(this.tournament.ParticipantsSwappable);
            Assert.IsFalse(this.tournament.TeamConvertable);
            Assert.IsFalse(this.tournament.GroupStagesWereStarted);

            // In order to test swiss_rounds we need some participants in the tournament.
            this.target.ParticipantCreate(this.tournament, new ParticipantCreateParameters {
                Name = Utilities.RandomName()
            });
            this.target.ParticipantCreate(this.tournament, new ParticipantCreateParameters {
                Name = Utilities.RandomName()
            });
            this.target.ParticipantCreate(this.tournament, new ParticipantCreateParameters {
                Name = Utilities.RandomName()
            });
            this.target.ParticipantCreate(this.tournament, new ParticipantCreateParameters {
                Name = Utilities.RandomName()
            });

            const string NewDescription      = "My awesome Description";
            const int    NewSignupCap        = 16;
            int?         newCheckInDuration  = 10;
            DateTime     newStartAt          = DateTime.Now.AddHours(1.0);
            const double NewPtsForMatchWin   = 2.0;
            const double NewPtsForMatchTie   = 3.0;
            const double NewPtsForGameWin    = 4.0;
            const double NewPtsForGameTie    = 5.0;
            const double NewPtsForBye        = 6.0;
            const int    NewSwissRounds      = 2;
            const double NewRrPtsForMatchWin = 7.0;
            const double NewRrPtsForMatchTie = 8.0;
            const double NewRrPtsForGameWin  = 9.0;
            const double NewRrPtsForGameTie  = 10.0;

            var updateParameters = new TournamentUpdateParameters
            {
                Description                      = NewDescription,
                OpenSignup                       = true,
                AcceptAttachments                = true,
                HideForum                        = true,
                ShowRounds                       = true,
                Private                          = true,
                NotifyUsersWhenMatchesOpen       = false,
                NotifyUsersWhenTheTournamentEnds = false,
                SequentialPairings               = true,
                SignupCap                        = NewSignupCap,
                StartAt                          = newStartAt,
                CheckInDuration                  = newCheckInDuration,
                PtsForMatchWin                   = NewPtsForMatchWin,
                PtsForMatchTie                   = NewPtsForMatchTie,
                PtsForGameWin                    = NewPtsForGameWin,
                PtsForGameTie                    = NewPtsForGameTie,
                PtsForBye                        = NewPtsForBye,
                SwissRounds                      = NewSwissRounds,
                RrPtsForMatchWin                 = NewRrPtsForMatchWin,
                RrPtsForMatchTie                 = NewRrPtsForMatchTie,
                RrPtsForGameWin                  = NewRrPtsForGameWin,
                RrPtsForGameTie                  = NewRrPtsForGameTie,
                RankedBy                         = TournamentRankedBy.GameWins
            };

            var updatedTournament = this.target.TournamentUpdate(this.tournament, updateParameters);

            Assert.AreEqual(NewDescription, updatedTournament.Description);
            Assert.IsTrue(updatedTournament.OpenSignup);
            Assert.IsTrue(updatedTournament.AcceptAttachments);
            Assert.IsTrue(updatedTournament.HideForum);
            Assert.IsTrue(updatedTournament.ShowRounds);
            Assert.IsTrue(updatedTournament.IsPrivate);
            Assert.IsFalse(updatedTournament.NotifyUsersWhenMatchesOpen);
            Assert.IsFalse(updatedTournament.NotifyUsersWhenTheTournamentEnds);
            Assert.IsTrue(updatedTournament.SequentialPairings);
            Assert.AreEqual(NewSignupCap, updatedTournament.SignupCap);
            Assert.IsTrue(updatedTournament.StartAt.HasValue);
            Utilities.AssertDateTimeWithin(newStartAt, updatedTournament.StartAt.Value, new TimeSpan(hours: 0, minutes: 1, seconds: 0));
            Assert.AreEqual(newCheckInDuration, updatedTournament.CheckInDuration);

            Assert.AreEqual(NewPtsForMatchWin, updatedTournament.PtsForMatchWin);
            Assert.AreEqual(NewPtsForMatchTie, updatedTournament.PtsForMatchTie);
            Assert.AreEqual(NewPtsForGameWin, updatedTournament.PtsForGameWin);
            Assert.AreEqual(NewPtsForGameTie, updatedTournament.PtsForGameTie);
            Assert.AreEqual(NewPtsForBye, updatedTournament.PtsForBye);
            Assert.AreEqual(NewSwissRounds, updatedTournament.SwissRounds);
            Assert.AreEqual(TournamentRankedBy.GameWins, updatedTournament.RankedBy);
            Assert.AreEqual(NewRrPtsForMatchWin, updatedTournament.RrPtsForMatchWin);
            Assert.AreEqual(NewRrPtsForMatchTie, updatedTournament.RrPtsForMatchTie);
            Assert.AreEqual(NewRrPtsForGameWin, updatedTournament.RrPtsForGameWin);
            Assert.AreEqual(NewRrPtsForGameTie, updatedTournament.RrPtsForGameTie);
        }