public async Task cannot_delete_existing_agent_profile_with_invalid_etag() { // Arrange var state = new AgentProfileDocument <string>() { Content = "foo", ETag = ETAG }; var request = DeleteAgentProfileRequest.Create(state); request.Agent = new Agent() { Name = AGENT_NAME, MBox = new Uri(AGENT_MBOX) }; request.ProfileId = PROFILE_ID; this._mockHttp .When(HttpMethod.Delete, this.GetApiUrl("agents/profile")) .WithQueryString("agent", AGENT_QS) .WithQueryString("profileId", PROFILE_ID) .WithHeaders("If-Match", ETAG) .Respond(HttpStatusCode.PreconditionFailed); // Act bool result = await this._client.AgentProfiles.Delete(request); // Assert result.Should().BeFalse(); }
public async Task can_delete_existing_agent_profile() { // Arrange var state = new AgentProfileDocument <string>() { Content = "foo" }; var request = DeleteAgentProfileRequest.Create(state); request.Agent = new Agent() { Name = AGENT_NAME, MBox = new Uri(AGENT_MBOX) }; request.ProfileId = PROFILE_ID; this._mockHttp .When(HttpMethod.Delete, this.GetApiUrl("agents/profile")) .WithQueryString("agent", AGENT_QS) .WithQueryString("profileId", PROFILE_ID) .With(x => x.Headers.IfNoneMatch.Count == 0 && x.Headers.IfMatch.Count == 0) .Respond(HttpStatusCode.NoContent); // Act bool result = await this._client.AgentProfiles.Delete(request); // Assert result.Should().BeTrue(); }
private void CompleteOptions(RequestOptions options, DeleteAgentProfileRequest request) { this.CompleteOptionsBase(options, request); if (!string.IsNullOrEmpty(request.ETag)) { this.AddETagHeader(options, request.ETag); } }
async Task <bool> IAgentProfilesApi.Delete(DeleteAgentProfileRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } request.Validate(); var options = new RequestOptions(ENDPOINT); this.CompleteOptions(options, request); try { await this._client.Delete(options); return(true); } catch (PreConditionFailedException) { return(false); } }