void ExecuteUpdateConfigCore(Func<DashServer.ManagementAPI.Models.Configuration, UpdateConfigStatus.ConfigUpdate> processResponse) { ExecuteCore(() => { var retval = new ExecuteCoreOutputs(); var currentConfig = this.ConfigController.GetCurrentConfiguration().Result as OkNegotiatedContentResult<DashServer.ManagementAPI.Models.Configuration>; Assert.IsNotNull(currentConfig); var updatedConfig = currentConfig.Content; this.UpdateConfigAction(updatedConfig); NegotiatedContentResult<DashServer.ManagementAPI.Models.Configuration> updateResponse = null; try { var response = this.ConfigController.UpdateConfiguration(updatedConfig).Result; updateResponse = response as NegotiatedContentResult<DashServer.ManagementAPI.Models.Configuration>; if (updateResponse == null && !this.ExpectedException && !this.ExpectedAbnormalResponse) { Assert.Fail("Unexpected response from ConfigurationController.UpdateConfiguration. Response type: {0}. Details: {1}", response.GetType().FullName, response); } } catch (Exception ex) { if (!this.ExpectedException) { throw; } retval.ThrownException = ex; } if (!this.ExpectedException && !this.ExpectedAbnormalResponse) { Assert.IsNotNull(updateResponse); Assert.AreEqual(HttpStatusCode.Accepted, updateResponse.StatusCode); updatedConfig = updateResponse.Content; retval.OperationStatus = processResponse(updatedConfig); retval.OperationId = updatedConfig.OperationId; retval.OperationCompletedNormally = retval.OperationStatus != null && retval.OperationStatus.State == UpdateConfigStatus.States.Completed; } this.VerifyConfigAction(this.UpdatedServiceConfig == null ? null : AzureServiceConfiguration.GetSettingsProjected(this.UpdatedServiceConfig), retval.OperationStatus, retval.ThrownException); return retval; }); }
void ExecuteSoftwareUpgradeCore(Func<string, UpdateConfigStatus.ConfigUpdate> processResponse) { ExecuteCore(() => { var retval = new ExecuteCoreOutputs(); IHttpActionResult response = null; try { response = this.UpgradeController.Update(new UpdateVersion { Version = this.UpgradeVersion }).Result; } catch (Exception ex) { if (!this.ExpectedException) { throw; } retval.ThrownException = ex; } if (!this.ExpectedException && !this.ExpectedAbnormalResponse) { var contentResponse = response as NegotiatedContentResult<OperationResult>; Assert.IsNotNull(contentResponse); Assert.AreEqual(HttpStatusCode.Accepted, contentResponse.StatusCode); retval.OperationStatus = processResponse(retval.OperationId = contentResponse.Content.OperationId); retval.OperationCompletedNormally = true; } this.VerifyUpgradeAction(response, this.UpdatedUpgradeParams); return retval; }); }