-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathUserAgentTest.cs
39 lines (30 loc) · 1.04 KB
/
UserAgentTest.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
using System.Linq;
using RingCentral.Net.Events;
using Xunit;
namespace RingCentral.Tests;
[Collection("Sequential")]
public class UserAgentTest
{
[Fact]
public async void AfterCall()
{
var rc = await ReusableRestClient.GetInstance();
var eventsExtension = new EventsExtension();
await rc.InstallExtension(eventsExtension);
var count = 0;
void EventHandler(object sender, HttpMessages httpMessages)
{
var userAgent = httpMessages.httpRequestMessage.Headers
.First(i => i.Key == "X-User-Agent").Value.ToArray();
Assert.Single(userAgent);
Assert.StartsWith("Unknown/0.0.1 RingCentral.Net/", userAgent[0]);
count += 1;
}
eventsExtension.RequestSuccess += EventHandler;
var china = await rc.Restapi().Dictionary().Country("46").Get();
Assert.Equal("China", china.name);
Assert.Equal(1, count);
eventsExtension.RequestSuccess -= EventHandler;
eventsExtension.enabled = false;
}
}