Skip to content
Snippets Groups Projects
Commit 87c3184f authored by Klaus Fischer's avatar Klaus Fischer
Browse files

Need to add a new contructor to Attachment class

parent de77d86a
No related branches found
No related tags found
2 merge requests!28773 direct submission status,!27Draft: Issue/830 http header add version
...@@ -20,6 +20,10 @@ public class StraightForwardTest : EndToEndTestBase { ...@@ -20,6 +20,10 @@ public class StraightForwardTest : EndToEndTestBase {
.WithJsonData(@"{""data"":""value""}") .WithJsonData(@"{""data"":""value""}")
.WithAttachments(new Attachment("Test.pdf", "Attachment #1"), .WithAttachments(new Attachment("Test.pdf", "Attachment #1"),
new Attachment("Test.pdf", "Attachment #2")) new Attachment("Test.pdf", "Attachment #2"))
.WithAttachments(new Attachment("Test.pdf", "Attachment #3"))
// .WithAttachments("TestForm.pdf", "StreamReader",
// System.Net.Mime.MediaTypeNames.Application.Pdf,
// new FileStream("Test.pdf", FileMode.Open, FileAccess.Read))
.Build(); .Build();
var submission = Sender.SendAsync(outgoing).Result; var submission = Sender.SendAsync(outgoing).Result;
...@@ -86,7 +90,7 @@ public class StraightForwardTest : EndToEndTestBase { ...@@ -86,7 +90,7 @@ public class StraightForwardTest : EndToEndTestBase {
attachments.First().Filename.Should().Be("Test.pdf"); attachments.First().Filename.Should().Be("Test.pdf");
attachments.TrueForAll(a => a.Description?.StartsWith("Attachment #") ?? false).Should() attachments.TrueForAll(a => a.Description?.StartsWith("Attachment #") ?? false).Should()
.BeTrue(); .BeTrue();
attachments.Count.Should().Be(3);
subscriberWithSubmission.AcceptSubmissionAsync().Wait(); subscriberWithSubmission.AcceptSubmissionAsync().Wait();
} }
......
...@@ -19,8 +19,29 @@ public class SubmissionBuilder : ISubmissionWithDestination, ...@@ -19,8 +19,29 @@ public class SubmissionBuilder : ISubmissionWithDestination,
return WithAttachments(attachments.ToArray()); return WithAttachments(attachments.ToArray());
} }
public ISubmissionWithData WithAttachments(string fileName, string description, string mimeType,
FileStream fileStream) {
byte[] buffer = null;
using (fileStream) {
buffer = new byte[fileStream.Length];
fileStream.Read(buffer, 0, (int)fileStream.Length);
}
var attachment = new Attachment(fileName, description, mimeType) {
Content = buffer
};
return WithAttachments(attachment);
}
public ISubmissionWithData WithAttachments(params Attachment[] attachments) { public ISubmissionWithData WithAttachments(params Attachment[] attachments) {
_submissionToSend.Attachments = attachments; _submissionToSend.Attachments ??= new Attachment[] { };
foreach (var attachment in attachments) {
_submissionToSend.Attachments =
_submissionToSend.Attachments.Append(attachment).ToArray();
}
return this; return this;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment