-
Notifications
You must be signed in to change notification settings - Fork 238
Expand file tree
/
Copy pathUpdate.cs
More file actions
81 lines (74 loc) · 2.36 KB
/
Update.cs
File metadata and controls
81 lines (74 loc) · 2.36 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using SlackAPI.Tests.Configuration;
using SlackAPI.Tests.Helpers;
using System;
using Xunit;
namespace SlackAPI.Tests
{
[Collection("Integration tests")]
public class Update
{
private readonly IntegrationFixture fixture;
public Update(IntegrationFixture fixture)
{
this.fixture = fixture;
}
[Fact]
public void SimpleUpdate()
{
// given
var client = this.fixture.UserClient;
var messageId = PostedMessage(client);
UpdateResponse actual = null;
// when
using (var sync = new InSync(nameof(SlackClient.Update)))
{
client.Update(
response =>
{
actual = response;
sync.Proceed();
},
messageId,
this.fixture.Config.TestChannelId,
"[changed]",
attachments: SlackMother.SomeAttachments,
as_user: true);
}
// then
Assert.True(actual.ok, "Error while posting message to channel. ");
Assert.Equal(actual.message.text, "[changed]");
Assert.Equal(actual.message.type, "message");
}
private string PostedMessage(SlackSocketClient client)
{
string messageId = null;
using (var sync = new InSync(nameof(SlackClient.PostMessage)))
{
client.PostMessage(
response =>
{
messageId = response.ts;
Assert.True(response.ok, "Error while posting message to channel. ");
sync.Proceed();
},
this.fixture.Config.TestChannelId,
"Hi there!",
as_user: true);
}
return messageId;
}
[Fact]
public void UpdatePresence()
{
var client = this.fixture.UserClient;
using (var sync = new InSync(nameof(SlackClient.EmitPresence)))
{
client.EmitPresence((presence) =>
{
presence.AssertOk();
sync.Proceed();
}, Presence.away);
}
}
}
}