-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTestTdtUdp.cs
60 lines (53 loc) · 1.55 KB
/
TestTdtUdp.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SynapseTools;
using System.Linq;
using System.Net.Sockets;
namespace SynapseToolsTests
{
[TestClass]
public class TestTdtUdp
{
public TestTdtUdp()
{
}
[TestMethod]
public void TestCreateClient()
{
var client = new TdtUdp("localhost");
}
[TestMethod, ExpectedException(typeof(SocketException))]
public void TestSendData()
{
int iterations = 100;
int packetLength = 4;
Random randNum = new Random();
var client = new TdtUdp("localhost");
for(int i=0; i< iterations; i++)
{
float[] data = new float[packetLength];
for(int j=0; j< packetLength; j++)
{
data[j] = (float)j;
}
client.Send(data);
Thread.Sleep(500);
}
}
[TestMethod, ExpectedException(typeof(SocketException))]
public void TestReceiveData()
{
int iterations = 1000;
var client = new TdtUdp("172.17.50.89");
for (int i = 0; i < iterations; i++)
{
float[] data = client.Receive<float>();
//Debug.WriteLine(data);
Debug.WriteLine("[{0}]", string.Join(", ", data.Select(v => v.ToString())));
}
}
}
}