]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Fix a couple of flaky tests that didn't match usage expectations
authorForest <chocozilla@gmail.com>
Wed, 7 Jul 2021 05:16:38 +0000 (22:16 -0700)
committerForest <chocozilla@gmail.com>
Wed, 7 Jul 2021 05:16:38 +0000 (22:16 -0700)
Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs
Hazel.UnitTests/UnityUdpConnectionTests.cs

index a65355c96cac25fc2d88613eac35fc11040b6cd9..4be16280beb4d6bd5198d4533208fbdef3fb2d88 100644 (file)
@@ -5,6 +5,8 @@ using System.Threading;
 using Hazel.Udp;
 using Hazel.Udp.FewerThreads;
 using System.Net.Sockets;
+using System.Linq;
+using System.Collections;
 
 namespace Hazel.UnitTests
 {
@@ -461,12 +463,13 @@ namespace Hazel.UnitTests
             using (ThreadLimitedUdpConnectionListener listener = this.CreateListener(2, new IPEndPoint(IPAddress.Any, 4296), new TestLogger()))
             using (UdpConnection connection = this.CreateConnection(new IPEndPoint(IPAddress.Loopback, 4296), new TestLogger()))
             {
-                MessageReader received = null;
+                string received = null;
                 ManualResetEvent mutex = new ManualResetEvent(false);
 
                 connection.Disconnected += delegate (object sender, DisconnectedEventArgs args)
                 {
-                    received = args.Message;
+                    // We don't own the message, we have to read the string now
+                    received = args.Message.ReadString();
                     mutex.Set();
                 };
 
@@ -484,7 +487,7 @@ namespace Hazel.UnitTests
                 mutex.WaitOne();
 
                 Assert.IsNotNull(received);
-                Assert.AreEqual("Goodbye", received.ReadString());
+                Assert.AreEqual("Goodbye", received);
             }
         }
     }
index 0597df4fe3fa846a56a55f282d36679173e2c081..5151ae25fdb41a9addbb3633ff6261792a8e2dee 100644 (file)
@@ -449,12 +449,13 @@ namespace Hazel.UnitTests
             using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
             using (UdpConnection connection = new UnityUdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
             {
-                MessageReader received = null;
+                string received = null;
                 ManualResetEvent mutex = new ManualResetEvent(false);
 
                 connection.Disconnected += delegate (object sender, DisconnectedEventArgs args)
                 {
-                    received = args.Message;
+                    // We don't own the message, we have to read the string now
+                    received = args.Message.ReadString();
                     mutex.Set();
                 };
 
@@ -478,7 +479,7 @@ namespace Hazel.UnitTests
                 mutex.WaitOne();
 
                 Assert.IsNotNull(received);
-                Assert.AreEqual("Goodbye", received.ReadString());
+                Assert.AreEqual("Goodbye", received);
             }
         }
     }