public void ImportSolution_ImportJobSuccess_SetsIsSuccessfulToTrue()
        {
            this.MockPasswordGrantConfiguredContext();
            this.MockAccessTokenResult();
            var failedImportJobData = ImportJobData.ParseXml($"<solutionManifest><result result=\"success\" errortext=\"\"></result></solutionManifest>");

            this.oDataSolutionServiceMock.SetReturnsDefault(Task.FromResult(failedImportJobData));

            var outputs = this.WorkflowInvoker.Invoke(this.GetValidInputs());

            Assert.Equal(true, outputs[nameof(ImportSolutionZip.IsSuccessful)]);
        }
        public void ImportSolution_ImportJobFailure_SetsError()
        {
            this.MockPasswordGrantConfiguredContext();
            this.MockAccessTokenResult();
            var error = "Missing dependencies";
            var failedImportJobData = ImportJobData.ParseXml($"<solutionManifest><result result=\"failure\" errortext=\"{error}\"></result></solutionManifest>");

            this.oDataSolutionServiceMock.SetReturnsDefault(Task.FromResult(failedImportJobData));

            var outputs = this.WorkflowInvoker.Invoke(this.GetValidInputs());

            Assert.Equal(error, outputs[nameof(ImportSolutionZip.Error)]);
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public async Task <ImportJobData> ImportSolutionZipAsync(byte[] solutionZip)
        {
            if (solutionZip == null)
            {
                throw new ArgumentNullException(nameof(solutionZip));
            }

            var importJobId = Guid.NewGuid();
            var request     = new ImportSolutionRequest
            {
                ImportJobId       = importJobId,
                CustomizationFile = Convert.ToBase64String(solutionZip),
                PublishWorkflows  = true,
                OverwriteUnmanagedCustomizations = true,
            };

            this.logWriter.Log(Severity.Info, Tag, $"Importing solution zip.");
            await this.oDataClient.PostAsync("ImportSolution", request).ConfigureAwait(false);

            this.logWriter.Log(Severity.Info, Tag, $"Retrieving import job {importJobId}.");
            var importJob = await this.importJobRepository.RetrieveAsync(importJobId).ConfigureAwait(false);

            return(ImportJobData.ParseXml(importJob.Data));
        }