-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathXmppInteroperabilityTests.cs
More file actions
73 lines (61 loc) · 1.76 KB
/
XmppInteroperabilityTests.cs
File metadata and controls
73 lines (61 loc) · 1.76 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
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;
using Waher.Networking.XMPP.Interoperability;
namespace Waher.Networking.XMPP.Test
{
[TestClass]
public class XmppInteroperabilityTests : CommunicationTests
{
private InteroperabilityClient interopClient;
private InteroperabilityServer interopServer;
[ClassInitialize]
public static void ClassInitialize(TestContext _)
{
SetupSnifferAndLog();
}
[ClassCleanup]
public static async Task ClassCleanup()
{
await DisposeSnifferAndLog();
}
public override async Task ConnectClients()
{
await base.ConnectClients();
Assert.AreEqual(XmppState.Connected, this.client1.State);
Assert.AreEqual(XmppState.Connected, this.client2.State);
this.interopClient = new InteroperabilityClient(this.client1);
this.interopServer = new InteroperabilityServer(this.client2);
this.interopServer.OnGetInterfaces += (Sender, e) =>
{
e.Add("Interface A", "Interface B", "Interface C", "Interface D");
return Task.CompletedTask;
};
}
public override Task DisposeClients()
{
this.interopServer.Dispose();
this.interopServer = null;
this.interopClient.Dispose();
this.interopClient = null;
return base.DisposeClients();
}
[TestMethod]
public async Task Interoperability_Test_01_GetInterfaces()
{
await this.ConnectClients();
try
{
string[] Interfaces = this.interopClient.GetInterfaces(this.client2.FullJID, 10000);
Assert.AreEqual(4, Interfaces.Length);
Assert.AreEqual("Interface A", Interfaces[0]);
Assert.AreEqual("Interface B", Interfaces[1]);
Assert.AreEqual("Interface C", Interfaces[2]);
Assert.AreEqual("Interface D", Interfaces[3]);
}
finally
{
await this.DisposeClients();
}
}
}
}