private static async Task <IList <ContestResponse> > CreateAndSaveChallengesAsync(string json, ILogger logger)
        {
            logger.LogInformation($"C# CreateChallenges function processing async: {json}");

            ChallengeRequest request = ContestFactory.CreateChallengeRequest(json);

            BlobApi       blobApi = await BlobApi.Instance;
            CloudSkillApi cscApi  = await CloudSkillApi.Instance;

            Tuple <IList <ContestResponse>, string> tuple = await blobApi.GetAllContestTupleAsync(request.BaseInputs.Mstpid);

            if (tuple?.Item1 != null)
            {
                request.LearningPaths = RemoveDuplicateLearningPaths(request, tuple.Item1);
                await blobApi.DeleteBlobAsync(tuple.Item2);
            }

            List <ContestResponse> response = await cscApi.CreateChallengesAsyc(request);

            logger.LogInformation($"Created the Challenges. Saving response to blob");

            if (tuple?.Item1 != null)
            {
                foreach (ContestResponse contest in tuple.Item1)
                {
                    response.Add(contest);
                }
            }

            await WriteToBlobAsync(request.BaseInputs, response);

            logger.LogInformation($"C# CreateChallenges function processed");

            return(response);
        }
Example #2
0
        public async Task CreateChallengesAsycTestAsync()
        {
            Configuration config = await TestHelper.GetConfigurationAsync();

            CloudSkillApi cscApi = new CloudSkillApi(config);

            string                 json               = ContestFactory.CreateChallengeRequestJson();
            ChallengeRequest       request            = ContestFactory.CreateChallengeRequest(json);
            List <ContestResponse> contestReponseList = await cscApi.CreateChallengesAsyc(request);

            Assert.IsTrue(contestReponseList.Count > 0);
        }