-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathClientHelper.cs
More file actions
44 lines (39 loc) · 1.41 KB
/
Copy pathClientHelper.cs
File metadata and controls
44 lines (39 loc) · 1.41 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
using System;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Polly;
using SlackAPI;
namespace IntegrationTest.Helpers
{
public static class ClientHelper
{
public static SlackSocketClient GetClient(string authToken)
{
var wait = new EventWaitHandle(false, EventResetMode.ManualReset);
var client = new SlackSocketClient(authToken);
client.Connect((x,sc) =>
{
Console.WriteLine("RTM Start");
}, () =>
{
Console.WriteLine("Connected");
wait.Set();
});
Policy
.Handle<AssertFailedException>()
.WaitAndRetry(15, x => TimeSpan.FromSeconds(0.2), (exception, span) => Console.WriteLine("Retrying in {0} seconds", span.TotalSeconds))
.Execute(() =>
{
Assert.IsTrue(wait.WaitOne(), "Still waiting for things to happen...");
});
Policy
.Handle<AssertFailedException>()
.WaitAndRetry(15, x => TimeSpan.FromSeconds(0.2), (exception, span) => Console.WriteLine("Retrying in {0} seconds", span.TotalSeconds))
.Execute(() =>
{
Assert.IsTrue(client.IsConnected, "Doh, still isn't connected");
});
return client;
}
}
}