Improve LocalConnectionTest (#1538)

This commit is contained in:
Lymdun 2020-03-02 22:41:27 +01:00 committed by GitHub
parent e9d4f04da5
commit ca166bd95f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine.TestTools;
namespace Mirror.Tests namespace Mirror.Tests
{ {
@ -34,6 +36,8 @@ public void Disconnect()
[Test] [Test]
public void ServerToClientTest() public void ServerToClientTest()
{ {
Assert.That(connectionToClient.address, Is.EqualTo("localhost"));
MyMessage myMessage = new MyMessage() MyMessage myMessage = new MyMessage()
{ {
id = 3, id = 3,
@ -64,6 +68,8 @@ void handler(NetworkMessage msg)
[Test] [Test]
public void ClientToServerTest() public void ClientToServerTest()
{ {
Assert.That(connectionToServer.address, Is.EqualTo("localhost"));
MyMessage myMessage = new MyMessage() MyMessage myMessage = new MyMessage()
{ {
id = 3, id = 3,
@ -91,5 +97,14 @@ void handler(NetworkMessage msg)
Assert.True(invoked, "handler should have been invoked"); Assert.True(invoked, "handler should have been invoked");
} }
[Test]
public void ClientToServerFailTest()
{
LogAssert.ignoreFailingMessages = true; // error log is expected
bool result = connectionToServer.Send(new ArraySegment<byte>(new byte[0]));
LogAssert.ignoreFailingMessages = false;
Assert.That(result, Is.False);
}
} }
} }