-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestingOutgoing.cs
40 lines (33 loc) · 1.03 KB
/
TestingOutgoing.cs
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
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.Add("theName", () => File.OpenRead("aFilePath"));
return context.Send(new OtherMessage(), options);
}
}
#endregion
#region TestOutgoing
[Fact]
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();
Assert.Contains("theName", attachment.Name);
Assert.True(attachments.HasPendingAttachments);
}
#endregion
}