]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Fix some tests I didn't notice I broke
authorForest <chocozilla@gmail.com>
Fri, 28 Dec 2018 07:23:03 +0000 (23:23 -0800)
committerForest <chocozilla@gmail.com>
Fri, 28 Dec 2018 07:23:03 +0000 (23:23 -0800)
Hazel.UnitTests/TestHelper.cs
Hazel.UnitTests/UdpConnectionTests.cs
Hazel.UnitTests/UnitTest1.cs
Hazel/Udp/UdpClientConnection.cs

index 6cb83a81b92f82eaae82de98ebb14f4914a51331..21857ff705eea55b9cd131ebaf3391c26e74f4bc 100644 (file)
@@ -23,7 +23,7 @@ namespace Hazel.UnitTests
             ManualResetEvent mutex = new ManualResetEvent(false);
 
             //Setup listener
-            listener.NewConnection += delegate(object sender, NewConnectionEventArgs ncArgs)
+            listener.NewConnection += delegate(NewConnectionEventArgs ncArgs)
             {
                 ncArgs.Connection.SendBytes(data, sendOption);
             };
@@ -32,7 +32,7 @@ namespace Hazel.UnitTests
 
             DataReceivedEventArgs args = null;
             //Setup conneciton
-            connection.DataReceived += delegate(object sender, DataReceivedEventArgs a)
+            connection.DataReceived += delegate(DataReceivedEventArgs a)
             {
                 Trace.WriteLine("Data was received correctly.");
 
@@ -75,9 +75,9 @@ namespace Hazel.UnitTests
 
             //Setup listener
             DataReceivedEventArgs result = null;
-            listener.NewConnection += delegate(object sender, NewConnectionEventArgs args)
+            listener.NewConnection += delegate(NewConnectionEventArgs args)
             {
-                args.Connection.DataReceived += delegate(object innerSender, DataReceivedEventArgs innerArgs)
+                args.Connection.DataReceived += delegate(DataReceivedEventArgs innerArgs)
                 {
                     Trace.WriteLine("Data was received correctly.");
 
@@ -125,9 +125,9 @@ namespace Hazel.UnitTests
                 mutex.Set();
             };
 
-            listener.NewConnection += delegate(object sender, NewConnectionEventArgs args)
+            listener.NewConnection += delegate(NewConnectionEventArgs args)
             {
-                args.Connection.Close();
+                args.Connection.Disconnect("Testing");
             };
 
             listener.Start();
@@ -147,7 +147,7 @@ namespace Hazel.UnitTests
             ManualResetEvent mutex = new ManualResetEvent(false);
             ManualResetEvent mutex2 = new ManualResetEvent(false);
 
-            listener.NewConnection += delegate(object sender, NewConnectionEventArgs args)
+            listener.NewConnection += delegate(NewConnectionEventArgs args)
             {
                 args.Connection.Disconnected += delegate(object sender2, DisconnectedEventArgs args2)
                 {
@@ -163,7 +163,7 @@ namespace Hazel.UnitTests
 
             mutex.WaitOne();
 
-            connection.Close();
+            connection.Disconnect("Testing");
 
             mutex2.WaitOne();
         }
index e5bc74a36d15ba5907307c6bae35926cc794fb3c..408eebd7d34baf37eb1f6627afeb05c716073cd7 100644 (file)
@@ -46,7 +46,7 @@ namespace Hazel.UnitTests
                 listener.Start();
 
                 MessageReader output = null;
-                listener.NewConnection += delegate (object sender, NewConnectionEventArgs e)
+                listener.NewConnection += delegate (NewConnectionEventArgs e)
                 {
                     output = e.HandshakeData;
                 };
@@ -69,9 +69,9 @@ namespace Hazel.UnitTests
             using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296, IPMode.IPv4)))
             {
                 MessageReader output = null;
-                listener.NewConnection += delegate (object sender, NewConnectionEventArgs e)
+                listener.NewConnection += delegate (NewConnectionEventArgs e)
                 {
-                    e.Connection.DataReceived += delegate (object s, DataReceivedEventArgs evt)
+                    e.Connection.DataReceived += delegate (DataReceivedEventArgs evt)
                     {
                         output = evt.Message;
                     };
@@ -103,9 +103,9 @@ namespace Hazel.UnitTests
             using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296, IPMode.IPv4)))
             {
                 listener.Start();
-                listener.NewConnection += delegate (object sender, NewConnectionEventArgs e)
+                listener.NewConnection += delegate (NewConnectionEventArgs e)
                 {
-                    e.Connection.DataReceived += delegate (object s, DataReceivedEventArgs evt)
+                    e.Connection.DataReceived += delegate (DataReceivedEventArgs evt)
                     {
                         Assert.IsTrue(Enumerable.SequenceEqual(evt.Message.Buffer, new byte[] { 3, 4 }));
                     };
@@ -141,7 +141,7 @@ namespace Hazel.UnitTests
             {
                 listener2.Start();
 
-                listener2.NewConnection += (sender, evt) =>
+                listener2.NewConnection += (evt) =>
                 {
                     Console.WriteLine("v6 connection: " + ((NetworkConnection)evt.Connection).GetIP4Address());
                 };
@@ -264,7 +264,7 @@ namespace Hazel.UnitTests
             using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
             using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
             {
-                listener.NewConnection += delegate(object sender, NewConnectionEventArgs args)
+                listener.NewConnection += delegate(NewConnectionEventArgs args)
                 {
                     ((UdpConnection)args.Connection).KeepAliveInterval = 100;
 
index 0abb7796756a1d5adb9dcd1cdc60fddac60520a0..7b0eb6e1279c24b8c6869d914f2151fcf249d662 100644 (file)
@@ -10,19 +10,18 @@ namespace Hazel.UnitTests
     [TestClass]
     public class UnitTest1
     {
-        // [TestMethod]
+        [TestMethod]
         public void StressTest()
         {
+            var ep = new NetworkEndPoint(IPAddress.Loopback, 22023);
             Parallel.For(0, 10000,
-                new ParallelOptions { MaxDegreeOfParallelism = 16 },
-                (i) =>
-            {
-                var ep = new NetworkEndPoint(IPAddress.Loopback, 22023);
-                using (var connection = new UdpClientConnection(ep))
-                {
-                    connection.Connect();
-                    Thread.Sleep(100);
-                }
+                new ParallelOptions { MaxDegreeOfParallelism = 64 },
+                (i) => {
+                    
+                var connection = new UdpClientConnection(ep);
+                connection.KeepAliveInterval = 50;
+
+                connection.Connect(new byte[5]);
             });
         }
     }
index fb3a86f2164586174dcad97fdcbe7005cd4585e1..1a74a46e6038df3a40a74241cc0841cd70041d35 100644 (file)
@@ -278,7 +278,7 @@ namespace Hazel.Udp
                 if (this.state == ConnectionState.Connected
                     || this.state == ConnectionState.Disconnecting)
                 {
-                    SendDisconnect();
+                    // SendDisconnect();
                     this.state = ConnectionState.NotConnected;
                 }
             }