public void AddGetRemoveAttachmentsFromIssue(Jira jira) { var summaryValue = "Test Summary with attachment " + _random.Next(int.MaxValue); var issue = new Issue(jira, "TST") { Type = "1", Summary = summaryValue, Assignee = "admin" }; // create an issue, verify no attachments issue.SaveChanges(); Assert.Empty(issue.GetAttachmentsAsync().Result); // upload multiple attachments File.WriteAllText("testfile1.txt", "Test File Content 1"); File.WriteAllText("testfile2.txt", "Test File Content 2"); issue.AddAttachment("testfile1.txt", "testfile2.txt"); // verify all attachments can be retrieved. var attachments = issue.GetAttachmentsAsync().Result; Assert.Equal(2, attachments.Count()); Assert.True(attachments.Any(a => a.FileName.Equals("testfile1.txt")), "'testfile1.txt' was not downloaded from server"); Assert.True(attachments.Any(a => a.FileName.Equals("testfile2.txt")), "'testfile2.txt' was not downloaded from server"); // verify properties of an attachment var attachment = attachments.First(); Assert.Equal("admin", attachment.Author); Assert.Equal("admin", attachment.AuthorUser.DisplayName); Assert.NotNull(attachment.CreatedDate); Assert.True(attachment.FileSize > 0); Assert.NotEmpty(attachment.MimeType); // download an attachment var tempFile = Path.GetTempFileName(); attachments.First(a => a.FileName.Equals("testfile1.txt")).Download(tempFile); Assert.Equal("Test File Content 1", File.ReadAllText(tempFile)); // remove an attachment issue.DeleteAttachmentAsync(attachments.First()).Wait(); Assert.Single(issue.GetAttachmentsAsync().Result); }