public void UpdateParticipant() { var tournamentName = Utilities.RandomName(); this.tournament = this.target.TournamentCreate(tournamentName, TournamentType.SingleElimination, tournamentName); var participant = this.target.ParticipantCreate(this.tournament, new ParticipantCreateParameters { ChallongeUsername = this.target.Username }); Assert.IsTrue(participant.Active); Assert.IsNull(participant.CheckedInAt); Assert.IsFalse(participant.CheckedIn); Assert.IsTrue(participant.CreatedAt.HasValue); Utilities.AssertDateTimeWithin(DateTime.Now, participant.CreatedAt.Value, new TimeSpan(hours: 0, minutes: 1, seconds: 0)); Assert.IsNull(participant.FinalRank); Assert.IsNull(participant.GroupId); Assert.IsNull(participant.Icon); Assert.IsTrue(participant.Id > 0); Assert.IsTrue(participant.InvitationId > 0); Assert.IsNull(participant.InviteEmail); Assert.IsNull(participant.Misc); Assert.IsNull(participant.Name); Assert.IsFalse(participant.OnWaitingList); Assert.AreEqual(1, participant.Seed); Assert.AreEqual(this.tournament.Id, participant.TournamentId); Assert.IsTrue(participant.UpdatedAt.HasValue); Utilities.AssertDateTimeWithin(DateTime.Now, participant.UpdatedAt.Value, new TimeSpan(hours: 0, minutes: 1, seconds: 0)); Assert.AreEqual(this.target.Username, participant.ChallongeUsername); Assert.IsNotNull(participant.ChallongeEmailAddressVerified); Assert.IsTrue(participant.ChallongeEmailAddressVerified == true); Assert.IsTrue(participant.Removable); Assert.IsTrue(participant.ParticipatableOrInvitationAttached); Assert.IsTrue(participant.ConfirmRemove); Assert.IsFalse(participant.InvitationPending); Assert.AreEqual(this.target.Username, participant.DisplayNameWithInvitationEmailAddress); Assert.IsNotNull(participant.EmailHash); Assert.AreEqual(this.target.Username, participant.Username); Assert.IsNull(participant.AttachedUserPortraitUrl); Assert.IsFalse(participant.CanCheckIn); Assert.IsFalse(participant.Reactivatable); const string NewMisc = "Foobar"; var updateParameter = new ParticipantUpdateParameters { Misc = NewMisc }; var updatedParticipant = this.target.ParticipantUpdate(this.tournament, participant, updateParameter); Assert.IsTrue(updatedParticipant.Active); Assert.IsNull(updatedParticipant.CheckedInAt); Assert.IsFalse(updatedParticipant.CheckedIn); Assert.IsTrue(updatedParticipant.CreatedAt.HasValue); Utilities.AssertDateTimeWithin(DateTime.Now, updatedParticipant.CreatedAt.Value, new TimeSpan(hours: 0, minutes: 1, seconds: 0)); Assert.IsNull(updatedParticipant.FinalRank); Assert.IsNull(updatedParticipant.GroupId); Assert.IsNull(updatedParticipant.Icon); Assert.IsTrue(updatedParticipant.Id > 0); Assert.IsTrue(updatedParticipant.InvitationId > 0); Assert.IsNull(updatedParticipant.InviteEmail); Assert.AreEqual(NewMisc, updatedParticipant.Misc); Assert.IsNull(updatedParticipant.Name); Assert.IsFalse(updatedParticipant.OnWaitingList); Assert.AreEqual(1, updatedParticipant.Seed); Assert.AreEqual(this.tournament.Id, updatedParticipant.TournamentId); Assert.IsTrue(updatedParticipant.UpdatedAt.HasValue); Utilities.AssertDateTimeWithin(DateTime.Now, updatedParticipant.UpdatedAt.Value, new TimeSpan(hours: 0, minutes: 1, seconds: 0)); Assert.AreEqual(this.target.Username, updatedParticipant.ChallongeUsername); Assert.IsNotNull(participant.ChallongeEmailAddressVerified); Assert.IsTrue(participant.ChallongeEmailAddressVerified.Value); Assert.IsTrue(updatedParticipant.Removable); Assert.IsTrue(updatedParticipant.ParticipatableOrInvitationAttached); Assert.IsTrue(updatedParticipant.ConfirmRemove); Assert.IsFalse(updatedParticipant.InvitationPending); Assert.AreEqual(this.target.Username, participant.DisplayNameWithInvitationEmailAddress); Assert.IsNotNull(updatedParticipant.EmailHash); Assert.AreEqual(this.target.Username, participant.Username); Assert.IsNull(updatedParticipant.AttachedUserPortraitUrl); Assert.IsFalse(updatedParticipant.CanCheckIn); Assert.IsFalse(updatedParticipant.Reactivatable); }
/// <summary> /// Change some information about a participant. /// </summary> /// <param name="tournament"></param> /// <param name="participant"></param> /// <param name="parameters"></param> /// <returns></returns> public Participant ParticipantUpdate(Tournament tournament, Participant participant, ParticipantUpdateParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var param = parameters.ToDictionary(); string url = string.Format("tournaments/{0}/participants/{1}", this.TournamentIdentifier(tournament), participant.Id); var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Put, param); return Deserializer.Participant(json); }
public void PaticipantUpdate() { const string Expected = "Test!"; var parameters = new ParticipantUpdateParameters { Misc = Expected }; Thread.Sleep(1500); var updatedParticipant = this.target.ParticipantUpdate(this.tournamentUnderTest, this.particiant1, parameters); Assert.AreEqual(Expected, updatedParticipant.Misc); Assert.IsNotNull(updatedParticipant.UpdatedAt); Assert.IsNotNull(this.particiant1.UpdatedAt); Utilities.AssertDateTimeWithin(updatedParticipant.UpdatedAt.Value, this.particiant1.UpdatedAt.Value, new TimeSpan(hours: 0, minutes: 1, seconds: 0)); }