mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Tests: LocalConnectionsTest ServerToClient
This commit is contained in:
parent
9aa48d6b8a
commit
02ff1076f8
@ -1,15 +1,11 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace Mirror.Tests
|
namespace Mirror.Tests
|
||||||
{
|
{
|
||||||
public class LocalConnectionTest
|
public class LocalConnectionTest
|
||||||
{
|
{
|
||||||
|
struct TestMessage : NetworkMessage {}
|
||||||
/*class MyMessage : MessageBase
|
|
||||||
{
|
|
||||||
public int id;
|
|
||||||
public string name;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
LocalConnectionToClient connectionToClient;
|
LocalConnectionToClient connectionToClient;
|
||||||
LocalConnectionToServer connectionToServer;
|
LocalConnectionToServer connectionToServer;
|
||||||
@ -30,37 +26,27 @@ public void Disconnect()
|
|||||||
connectionToServer.Disconnect();
|
connectionToServer.Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[Test]
|
[Test]
|
||||||
public void ServerToClientTest()
|
public void ServerToClient()
|
||||||
{
|
{
|
||||||
Assert.That(connectionToClient.address, Is.EqualTo("localhost"));
|
Assert.That(connectionToClient.address, Is.EqualTo("localhost"));
|
||||||
|
|
||||||
MyMessage myMessage = new MyMessage()
|
|
||||||
{
|
|
||||||
id = 3,
|
|
||||||
name = "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
bool invoked = false;
|
bool invoked = false;
|
||||||
|
void Handler(NetworkConnection conn, NetworkReader reader, int channelId)
|
||||||
void handler(NetworkConnection conn, NetworkReader reader, int channelId)
|
|
||||||
{
|
{
|
||||||
MyMessage received = msg.ReadMessage<MyMessage>();
|
|
||||||
Assert.That(received.id, Is.EqualTo(3));
|
|
||||||
Assert.That(received.name, Is.EqualTo("hello"));
|
|
||||||
invoked = true;
|
invoked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<int, NetworkMessageDelegate> handlers = new Dictionary<int, NetworkMessageDelegate>();
|
Dictionary<ushort, NetworkMessageDelegate> handlers = new Dictionary<ushort, NetworkMessageDelegate>();
|
||||||
handlers.Add(MessagePacker.GetId<MyMessage>(), handler);
|
handlers.Add(MessagePacking.GetId<TestMessage>(), Handler);
|
||||||
|
|
||||||
connectionToClient.SetHandlers(handlers);
|
connectionToClient.SetHandlers(handlers);
|
||||||
connectionToServer.Send(myMessage);
|
connectionToServer.Send(new TestMessage());
|
||||||
|
|
||||||
connectionToServer.Update();
|
connectionToServer.Update();
|
||||||
|
|
||||||
Assert.True(invoked, "handler should have been invoked");
|
Assert.True(invoked, "handler should have been invoked");
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/*[Test]
|
/*[Test]
|
||||||
public void ClientToServerTest()
|
public void ClientToServerTest()
|
||||||
|
Loading…
Reference in New Issue
Block a user