/// <summary> /// Initializes a new instance of a RestoreOperation for mocking purposes. /// </summary> /// <param name="value">The <see cref="RestoreDetailsInternal" /> that will be used to populate various properties.</param> /// <param name="response">The <see cref="Response" /> that will be returned from <see cref="GetRawResponse" />.</param> /// <param name="client">An instance of <see cref="KeyVaultBackupClient" />.</param> /// <exception cref="ArgumentNullException"><paramref name="value"/> or <paramref name="response"/> or <paramref name="client"/> is null.</exception> internal RestoreOperation(RestoreDetailsInternal value, Response response, KeyVaultBackupClient client) { Argument.AssertNotNull(value, nameof(value)); Argument.AssertNotNull(response, nameof(response)); Argument.AssertNotNull(client, nameof(client)); _client = client; _response = response; _value = value; _id = value.JobId; }
/// <inheritdoc/> public override Response UpdateStatus(CancellationToken cancellationToken = default) { if (!HasCompleted) { Response <RestoreDetailsInternal> response = _client.GetRestoreDetails(Id, cancellationToken); _value = response.Value; _response = response.GetRawResponse(); } return(GetRawResponse()); }
/// <inheritdoc/> public override async ValueTask <Response> UpdateStatusAsync(CancellationToken cancellationToken = default) { if (!HasCompleted) { Response <RestoreDetailsInternal> response = await _client.GetRestoreDetailsAsync(Id, cancellationToken).ConfigureAwait(false); _value = response.Value; _response = response.GetRawResponse(); } return(GetRawResponse()); }
/// <summary> /// Initializes a new instance of a RestoreOperation for mocking purposes. /// </summary> /// <param name="value">The response value that will be used to populate various properties.</param> /// <param name="response">The <see cref="Response" /> that will be returned from <see cref="GetRawResponse" />.</param> /// <param name="client">An instance of <see cref="KeyVaultBackupClient" />.</param> /// <exception cref="ArgumentNullException"><paramref name="value"/> or <paramref name="response"/> or <paramref name="client"/> is null.</exception> internal RestoreOperationInternal(TResponseType value, Response response, KeyVaultBackupClient client) { Argument.AssertNotNull(value, nameof(value)); Argument.AssertNotNull(response, nameof(response)); Argument.AssertNotNull(client, nameof(client)); _client = client; _response = response; _value = value; _id = value switch { SelectiveKeyRestoreDetailsInternal r => r.JobId, RestoreDetailsInternal r => r.JobId, null => default,
public void Setup() { DateTimeOffset now = DateTimeOffset.Now; failedRestore = new RestoreDetailsInternal( "failed", "failure details", new KeyVaultServiceError("500", "failed restore", null), JobId, DateTimeOffset.Now.AddMinutes(-5), now); incompleteRestore = new RestoreDetailsInternal( "in progress", "", null, JobId, DateTimeOffset.Now.AddMinutes(-5), null); failedResponse = new Mock <Response <RestoreDetailsInternal> >(); failedResponse.SetupGet(m => m.Value).Returns(failedRestore); }
/// <summary> /// Initializes a new instance of a RestoreOperation for mocking purposes. /// </summary> /// <param name="value">The <see cref="RestoreDetailsInternal" /> that will be used to populate various properties.</param> /// <param name="response">The <see cref="Response" /> that will be returned from <see cref="GetRawResponse" />.</param> /// <param name="client">An instance of <see cref="KeyVaultBackupClient" />.</param> /// <exception cref="ArgumentNullException"><paramref name="value"/> or <paramref name="response"/> or <paramref name="client"/> is null.</exception> internal RestoreOperation(RestoreDetailsInternal value, Response response, KeyVaultBackupClient client) { _operationInternal = new RestoreOperationInternal <AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders, RestoreResult, RestoreDetailsInternal>(value, response, client); }