public void Flow_tests() { var putDocResponse = Client.Documents.PostAsync(TestData.Artists.Artist1Json).Result; var putCmd = new PutAttachmentCommand( putDocResponse.Id, putDocResponse.Rev, TestData.Attachments.One.Name, TestData.Attachments.One.ContentType, TestData.Attachments.One.ContentDecoded.AsBytes()); var putAttachmentResponse = SUT.PutAsync(putCmd).Result; putAttachmentResponse.Should().BeSuccessfulPut(TestData.Artists.Artist1Id); var getCmd = new GetAttachmentCommand( putAttachmentResponse.Id, putAttachmentResponse.Rev, TestData.Attachments.One.Name); var getResponse = SUT.GetAsync(getCmd).Result; getResponse.Should().BeSuccessfulGet(TestData.Artists.Artist1Id, TestData.Attachments.One.Name); var deleteCmd = new DeleteAttachmentCommand( putAttachmentResponse.Id, putAttachmentResponse.Rev, TestData.Attachments.One.Name); var deleteResponse = SUT.DeleteAsync(deleteCmd).Result; deleteResponse.Should().BeSuccessfulDelete(TestData.Artists.Artist1Id); }
protected virtual HttpRequestMessage CreateRequest(GetAttachmentCommand cmd) { var req = new HttpRequest(HttpMethod.Get, GenerateRequestUrl(cmd.DocId, cmd.DocRev, cmd.Name)); req.SetIfMatch(cmd.DocRev); return(req); }
public virtual async Task <AttachmentResponse> GetAsync(GetAttachmentCommand cmd) { Ensure.That(cmd, "cmd").IsNotNull(); var req = CreateRequest(cmd); var res = SendAsync(req); return(ProcessAttachmentResponse(await res.ForAwait())); }
public void When_GET_of_an_existing_attachment_Using_id_The_attachment_is_returned_correctly() { var putDocResponse = Client.Documents.PostAsync(TestData.Artists.Artist1Json).Result; var putCmd = new PutAttachmentCommand( putDocResponse.Id, putDocResponse.Rev, TestData.Attachments.One.Name, TestData.Attachments.One.ContentType, TestData.Attachments.One.ContentDecoded.AsBytes()); var putAttachmentResponse = SUT.PutAsync(putCmd).Result; var getCmd = new GetAttachmentCommand( putAttachmentResponse.Id, TestData.Attachments.One.Name); var getAttachmentResponse = SUT.GetAsync(getCmd).Result; getAttachmentResponse.Should().BeSuccessfulGet(TestData.Artists.Artist1Id, TestData.Attachments.One.Name); getAttachmentResponse.Content.AsBase64EncodedString().Should().Be(TestData.Attachments.One.ContentEncoded); }
public static Task <AttachmentResponse> ExecuteAsync(this IClient client, GetAttachmentCommand cmd) { return(client.Attachments.GetAsync(cmd)); }