コード例 #1
0
 public CreatedSmokeTestApplication(ISmokeTestApplication source, ISmokeTestApplicationRepository smokeTestApplicationRepository, IApprendaTestSession session)
 {
     AppAlias = source.AppAlias;
     SmokeTestApplicationName        = source.SmokeTestApplicationName;
     _smokeTestApplicationRepository = smokeTestApplicationRepository;
     _session = session;
 }
        public async Task MarkAsNoLongerUsedByTest(IApprendaTestSession session, ISmokeTestApplication smApplication)
        {
            var numberUsing = _numberOfTestsUsingApplicationCurrently.ContainsKey(smApplication.AppAlias)
                ? _numberOfTestsUsingApplicationCurrently[smApplication.AppAlias]
                : 0;

            //do we have instances using it?
            if (numberUsing <= 1)
            {
                var client = await session.GetClient();

                try
                {
                    var res = await client.DeleteApplication(smApplication.AppAlias);
                }
                catch (Exception)
                {
                }
            }

            _numberOfTestsUsingApplicationCurrently[smApplication.AppAlias] = numberUsing - 1;
        }
        private async Task <string> CreateAppOnPlatform(IApprendaDeveloperPortalApiClient client, ISmokeTestApplication smApp)
        {
            //create it!
            var app = new Application("")
            {
                Alias       = smApp.AppAlias,
                Description = $"{smApp.SmokeTestApplicationName} created by Smoke Tests",
                Name        = $"st_{smApp.AppAlias}",
            };

            var res = await client.PostApp(app);

            if (!res)
            {
                throw new Exception("Error while posting application");
            }

            //check it exists!
            var getRes = await client.GetApplication(app.Alias);


            //check adding the archive
            var archive = await GetSmokeTestApplication(smApp.SmokeTestApplicationName);

            var rc = await client.PatchVersion(getRes.Alias, getRes.CurrentVersion.Alias, true,
                                               archive.ArchiveContents);

            if (rc.Status != ReportCardStatus.Succeeded)
            {
                throw new Exception($"Patching app returned status of {rc.Status}");
            }
            return(app.Alias);
        }