protected ListOfContestsResponse RetriveListOfContestsSync() { ListOfContestsResponse listOfContests = DoAsyncCallAsSynchronous <ListOfContestsResponse>( (Callback <ListOfContestsResponse> callback) => { WebService.RetrieveListOfContests(callback); }); return(listOfContests); }
public virtual void RetrieveListOfContestsTest() { ListOfContestsResponse listOfContestsResponse = RetriveListOfContestsSync(); Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, listOfContestsResponse.Status); Assert.IsNull(listOfContestsResponse.ErrorMessage); var listOfContests = listOfContestsResponse.ListOfContests; //in case there is not contest yet published attempt to publish one contest if (listOfContests.Count == 0) { //authenticate AuthenticationResponse authenticationResponse = AuthenticateSync(ValidCredentials); Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, authenticationResponse.Status); //create dummy contest var dummyContest = CreateDummyContest("RetrieveListOfContestsTest"); //publish contest Response response = PublishContestSync(authenticationResponse.Ticket, ValidCredentials.Username, dummyContest); Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, response.Status); } //try retrieving the list of contests again and check if there is at least one contest in the list listOfContestsResponse = RetriveListOfContestsSync(); Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, listOfContestsResponse.Status); Assert.IsNull(listOfContestsResponse.ErrorMessage); listOfContests = listOfContestsResponse.ListOfContests; Assert.IsTrue(listOfContests.Count > 0); //print list of contests foreach (Contest contest in listOfContests) { Assert.IsNotNull(contest); //check if contest is not null Assert.IsNull(contest.PackageFileContent); //package file content should be null - retrieving the list of contest should not load the package files System.Diagnostics.Debug.WriteLine(String.Format("Contest name: {0}, Author: {1}, Short Description: {2}, Contest Guid: {3}", contest.Name, contest.Author, contest.ShortDescription, contest.ContestGUID)); } }