-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTestingOutgoing.cs
More file actions
46 lines (39 loc) · 1.24 KB
/
TestingOutgoing.cs
File metadata and controls
46 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class TestingOutgoing
{
#region TestOutgoingHandler
public class Handler :
IHandleMessages<MyMessage>
{
public Task Handle(MyMessage message, HandlerContext context)
{
var options = new SendOptions();
var attachments = options.Attachments();
attachments.AddStream(
"theName",
async stream =>
{
await using var source = File.OpenRead("aFilePath");
await source.CopyToAsync(stream);
});
return context.Send(new OtherMessage(), options);
}
}
#endregion
#region TestOutgoing
[Test]
public async Task TestOutgoingAttachments()
{
//Arrange
var context = new RecordingHandlerContext();
var handler = new Handler();
//Act
await handler.Handle(new(), context);
// Assert
var sentMessage = context.Sent.Single();
var attachments = sentMessage.Options.Attachments();
var attachment = attachments.Items.Single();
await Assert.That(attachment.Name).Contains("theName");
await Assert.That(attachments.HasPendingAttachments).IsTrue();
}
#endregion
}