public async void TestAttachmentBytes() { var assembly = Assembly.GetExecutingAssembly(); Stream cloudcmsStream = assembly.GetManifestResourceStream("CloudCMS.res.cloudcms.png"); byte[] cloudcmsImage = ReadStreamBytes(cloudcmsStream); Stream headphonesStream = assembly.GetManifestResourceStream("CloudCMS.res.headphones.png"); byte[] headphonesImage = ReadStreamBytes(headphonesStream); IBranch branch = await Fixture.Repository.ReadBranchAsync("master"); INode node = (INode)await branch.CreateNodeAsync(); await node.UploadAttachmentAsync("default", cloudcmsImage, "image/png", "myImage"); List <IAttachment> attachments = await node.ListAttachments(); IAttachment attachment = attachments[0]; Assert.Equal("default", attachment.Id); Assert.Equal("myImage", attachment.Filename); Assert.Equal("image/png", attachment.ContentType); Assert.True(attachment.Length > 0); Assert.NotNull(attachment.ObjectId); byte[] download = await node.DownloadAttachmentBytesAsync(); Assert.NotEmpty(download); byte[] downloadCopy = await attachment.DownloadAsync(); Assert.Equal(download.Length, downloadCopy.Length); Dictionary <string, AttachmentContent> attachmentContents = new Dictionary <string, AttachmentContent>(); attachmentContents.Add("another", new AttachmentContent(headphonesImage, "image/png")); await node.UploadAttachmentsAsync(attachmentContents); attachments = await node.ListAttachments(); Assert.Equal(2, attachments.Count); await node.DeleteAttachmentAsync("default"); attachments = await node.ListAttachments(); Assert.Single(attachments); attachment = attachments[0]; Assert.Equal("another", attachment.Id); Assert.Equal("another", attachment.Filename); Assert.Equal("image/png", attachment.ContentType); Assert.True(attachment.Length > 0); Assert.NotNull(attachment.ObjectId); }