com.unity.netcode.gameobjects@1.0.0-pre.7
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0-pre.7] - 2022-04-01 ### Added - Added editor only check prior to entering into play mode if the currently open and active scene is in the build list and if not displays a dialog box asking the user if they would like to automatically add it prior to entering into play mode. (#1828) - Added `UnityTransport` implementation and `com.unity.transport` package dependency (#1823) - Added `NetworkVariableWritePermission` to `NetworkVariableBase` and implemented `Owner` client writable netvars. (#1762) - `UnityTransport` settings can now be set programmatically. (#1845) - `FastBufferWriter` and Reader IsInitialized property. (#1859) ### Changed - Updated `UnityTransport` dependency on `com.unity.transport` to 1.0.0 (#1849) ### Removed - Removed `SnapshotSystem` (#1852) - Removed `com.unity.modules.animation`, `com.unity.modules.physics` and `com.unity.modules.physics2d` dependencies from the package (#1812) - Removed `com.unity.collections` dependency from the package (#1849) ### Fixed - Fixed in-scene placed NetworkObjects not being found/ignored after a client disconnects and then reconnects. (#1850) - Fixed issue where `UnityTransport` send queues were not flushed when calling `DisconnectLocalClient` or `DisconnectRemoteClient`. (#1847) - Fixed NetworkBehaviour dependency verification check for an existing NetworkObject not searching from root parent transform relative GameObject. (#1841) - Fixed issue where entries were not being removed from the NetworkSpawnManager.OwnershipToObjectsTable. (#1838) - Fixed ClientRpcs would always send to all connected clients by default as opposed to only sending to the NetworkObject's Observers list by default. (#1836) - Fixed clarity for NetworkSceneManager client side notification when it receives a scene hash value that does not exist in its local hash table. (#1828) - Fixed client throws a key not found exception when it times out using UNet or UTP. (#1821) - Fixed network variable updates are no longer limited to 32,768 bytes when NetworkConfig.EnsureNetworkVariableLengthSafety is enabled. The limits are now determined by what the transport can send in a message. (#1811) - Fixed in-scene NetworkObjects get destroyed if a client fails to connect and shuts down the NetworkManager. (#1809) - Fixed user never being notified in the editor that a NetworkBehaviour requires a NetworkObject to function properly. (#1808) - Fixed PlayerObjects and dynamically spawned NetworkObjects not being added to the NetworkClient's OwnedObjects (#1801) - Fixed issue where NetworkManager would continue starting even if the NetworkTransport selected failed. (#1780) - Fixed issue when spawning new player if an already existing player exists it does not remove IsPlayer from the previous player (#1779) - Fixed lack of notification that NetworkManager and NetworkObject cannot be added to the same GameObject with in-editor notifications (#1777) - Fixed parenting warning printing for false positives (#1855)
This commit is contained in:
193
Tests/Editor/Transports/BatchedReceiveQueueTests.cs
Normal file
193
Tests/Editor/Transports/BatchedReceiveQueueTests.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Unity.Collections;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using Unity.Networking.Transport;
|
||||
|
||||
namespace Unity.Netcode.EditorTests
|
||||
{
|
||||
public class BatchedReceiveQueueTests
|
||||
{
|
||||
[Test]
|
||||
public void BatchedReceiveQueue_EmptyReader()
|
||||
{
|
||||
var data = new NativeArray<byte>(0, Allocator.Temp);
|
||||
|
||||
var reader = new DataStreamReader(data);
|
||||
var q = new BatchedReceiveQueue(reader);
|
||||
Assert.AreEqual(default(ArraySegment<byte>), q.PopMessage());
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedReceiveQueue_SingleMessage()
|
||||
{
|
||||
var dataLength = sizeof(int) + 1;
|
||||
|
||||
var data = new NativeArray<byte>(dataLength, Allocator.Temp);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
writer.WriteInt(1);
|
||||
writer.WriteByte((byte)42);
|
||||
|
||||
var reader = new DataStreamReader(data);
|
||||
var q = new BatchedReceiveQueue(reader);
|
||||
|
||||
Assert.False(q.IsEmpty);
|
||||
|
||||
var message = q.PopMessage();
|
||||
Assert.AreEqual(1, message.Count);
|
||||
Assert.AreEqual((byte)42, message.Array[message.Offset]);
|
||||
|
||||
Assert.AreEqual(default(ArraySegment<byte>), q.PopMessage());
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedReceiveQueue_MultipleMessages()
|
||||
{
|
||||
var dataLength = (sizeof(int) + 1) * 2;
|
||||
|
||||
var data = new NativeArray<byte>(dataLength, Allocator.Temp);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
writer.WriteInt(1);
|
||||
writer.WriteByte((byte)42);
|
||||
writer.WriteInt(1);
|
||||
writer.WriteByte((byte)142);
|
||||
|
||||
var reader = new DataStreamReader(data);
|
||||
var q = new BatchedReceiveQueue(reader);
|
||||
|
||||
Assert.False(q.IsEmpty);
|
||||
|
||||
var message1 = q.PopMessage();
|
||||
Assert.AreEqual(1, message1.Count);
|
||||
Assert.AreEqual((byte)42, message1.Array[message1.Offset]);
|
||||
|
||||
var message2 = q.PopMessage();
|
||||
Assert.AreEqual(1, message2.Count);
|
||||
Assert.AreEqual((byte)142, message2.Array[message2.Offset]);
|
||||
|
||||
Assert.AreEqual(default(ArraySegment<byte>), q.PopMessage());
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedReceiveQueue_PartialMessage()
|
||||
{
|
||||
var dataLength = sizeof(int);
|
||||
|
||||
var data = new NativeArray<byte>(dataLength, Allocator.Temp);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
writer.WriteInt(42);
|
||||
|
||||
var reader = new DataStreamReader(data);
|
||||
var q = new BatchedReceiveQueue(reader);
|
||||
|
||||
Assert.False(q.IsEmpty);
|
||||
Assert.AreEqual(default(ArraySegment<byte>), q.PopMessage());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedReceiveQueue_PushReader_ToFilledQueue()
|
||||
{
|
||||
var data1Length = sizeof(int);
|
||||
var data2Length = sizeof(byte);
|
||||
|
||||
var data1 = new NativeArray<byte>(data1Length, Allocator.Temp);
|
||||
var data2 = new NativeArray<byte>(data2Length, Allocator.Temp);
|
||||
|
||||
var writer1 = new DataStreamWriter(data1);
|
||||
writer1.WriteInt(1);
|
||||
var writer2 = new DataStreamWriter(data2);
|
||||
writer2.WriteByte(42);
|
||||
|
||||
var reader1 = new DataStreamReader(data1);
|
||||
var reader2 = new DataStreamReader(data2);
|
||||
|
||||
var q = new BatchedReceiveQueue(reader1);
|
||||
|
||||
Assert.False(q.IsEmpty);
|
||||
|
||||
q.PushReader(reader2);
|
||||
|
||||
Assert.False(q.IsEmpty);
|
||||
|
||||
var message = q.PopMessage();
|
||||
Assert.AreEqual(1, message.Count);
|
||||
Assert.AreEqual((byte)42, message.Array[message.Offset]);
|
||||
|
||||
Assert.AreEqual(default(ArraySegment<byte>), q.PopMessage());
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedReceiveQueue_PushReader_ToPartiallyFilledQueue()
|
||||
{
|
||||
var dataLength = sizeof(int) + 1;
|
||||
|
||||
var data = new NativeArray<byte>(dataLength, Allocator.Temp);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
writer.WriteInt(1);
|
||||
writer.WriteByte((byte)42);
|
||||
|
||||
var reader = new DataStreamReader(data);
|
||||
var q = new BatchedReceiveQueue(reader);
|
||||
|
||||
reader = new DataStreamReader(data);
|
||||
q.PushReader(reader);
|
||||
|
||||
var message = q.PopMessage();
|
||||
Assert.AreEqual(1, message.Count);
|
||||
Assert.AreEqual((byte)42, message.Array[message.Offset]);
|
||||
|
||||
reader = new DataStreamReader(data);
|
||||
q.PushReader(reader);
|
||||
|
||||
message = q.PopMessage();
|
||||
Assert.AreEqual(1, message.Count);
|
||||
Assert.AreEqual((byte)42, message.Array[message.Offset]);
|
||||
|
||||
message = q.PopMessage();
|
||||
Assert.AreEqual(1, message.Count);
|
||||
Assert.AreEqual((byte)42, message.Array[message.Offset]);
|
||||
|
||||
Assert.AreEqual(default(ArraySegment<byte>), q.PopMessage());
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedReceiveQueue_PushReader_ToEmptyQueue()
|
||||
{
|
||||
var dataLength = sizeof(int) + 1;
|
||||
|
||||
var data = new NativeArray<byte>(dataLength, Allocator.Temp);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
writer.WriteInt(1);
|
||||
writer.WriteByte((byte)42);
|
||||
|
||||
var reader = new DataStreamReader(data);
|
||||
var q = new BatchedReceiveQueue(reader);
|
||||
|
||||
Assert.False(q.IsEmpty);
|
||||
|
||||
q.PopMessage();
|
||||
|
||||
Assert.True(q.IsEmpty);
|
||||
|
||||
reader = new DataStreamReader(data);
|
||||
q.PushReader(reader);
|
||||
|
||||
var message = q.PopMessage();
|
||||
Assert.AreEqual(1, message.Count);
|
||||
Assert.AreEqual((byte)42, message.Array[message.Offset]);
|
||||
|
||||
Assert.AreEqual(default(ArraySegment<byte>), q.PopMessage());
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Tests/Editor/Transports/BatchedReceiveQueueTests.cs.meta
Normal file
11
Tests/Editor/Transports/BatchedReceiveQueueTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aabb21b30a80142ea86e59d1b4d5c587
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
266
Tests/Editor/Transports/BatchedSendQueueTests.cs
Normal file
266
Tests/Editor/Transports/BatchedSendQueueTests.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Unity.Collections;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using Unity.Networking.Transport;
|
||||
|
||||
namespace Unity.Netcode.EditorTests
|
||||
{
|
||||
public class BatchedSendQueueTests
|
||||
{
|
||||
private const int k_TestQueueCapacity = 1024;
|
||||
private const int k_TestMessageSize = 42;
|
||||
|
||||
private ArraySegment<byte> m_TestMessage;
|
||||
|
||||
private void AssertIsTestMessage(NativeArray<byte> data)
|
||||
{
|
||||
var reader = new DataStreamReader(data);
|
||||
Assert.AreEqual(k_TestMessageSize, reader.ReadInt());
|
||||
for (int i = 0; i < k_TestMessageSize; i++)
|
||||
{
|
||||
Assert.AreEqual(m_TestMessage.Array[i], reader.ReadByte());
|
||||
}
|
||||
}
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void InitializeTestMessage()
|
||||
{
|
||||
var data = new byte[k_TestMessageSize];
|
||||
for (int i = 0; i < k_TestMessageSize; i++)
|
||||
{
|
||||
data[i] = (byte)i;
|
||||
}
|
||||
m_TestMessage = new ArraySegment<byte>(data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_EmptyOnCreation()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
|
||||
Assert.AreEqual(0, q.Length);
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_NotCreatedAfterDispose()
|
||||
{
|
||||
var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
q.Dispose();
|
||||
Assert.False(q.IsCreated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_PushMessageReturnValue()
|
||||
{
|
||||
// Will fit a single test message, but not two (with overhead included).
|
||||
var queueCapacity = (k_TestMessageSize * 2) + BatchedSendQueue.PerMessageOverhead;
|
||||
|
||||
using var q = new BatchedSendQueue(queueCapacity);
|
||||
|
||||
Assert.True(q.PushMessage(m_TestMessage));
|
||||
Assert.False(q.PushMessage(m_TestMessage));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_LengthIncreasedAfterPush()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
Assert.AreEqual(k_TestMessageSize + BatchedSendQueue.PerMessageOverhead, q.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_PushedMessageGeneratesCopy()
|
||||
{
|
||||
var messageLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;
|
||||
var queueCapacity = messageLength * 2;
|
||||
|
||||
using var q = new BatchedSendQueue(queueCapacity);
|
||||
using var data = new NativeArray<byte>(k_TestQueueCapacity, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
q.Consume(messageLength);
|
||||
Assert.IsTrue(q.PushMessage(m_TestMessage));
|
||||
Assert.AreEqual(queueCapacity, q.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithMessages_ReturnValue()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(k_TestQueueCapacity, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
var filled = q.FillWriterWithMessages(ref writer);
|
||||
Assert.AreEqual(k_TestMessageSize + BatchedSendQueue.PerMessageOverhead, filled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithMessages_NoopIfNoPushedMessages()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(k_TestQueueCapacity, Allocator.Temp);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
Assert.AreEqual(0, q.FillWriterWithMessages(ref writer));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithMessages_NoopIfNotEnoughCapacity()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(2, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
Assert.AreEqual(0, q.FillWriterWithMessages(ref writer));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithMessages_SinglePushedMessage()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(k_TestQueueCapacity, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
q.FillWriterWithMessages(ref writer);
|
||||
AssertIsTestMessage(data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithMessages_MultiplePushedMessages()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(k_TestQueueCapacity, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
q.FillWriterWithMessages(ref writer);
|
||||
|
||||
var messageLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;
|
||||
AssertIsTestMessage(data);
|
||||
AssertIsTestMessage(data.GetSubArray(messageLength, messageLength));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithMessages_PartialPushedMessages()
|
||||
{
|
||||
var messageLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;
|
||||
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(messageLength, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
Assert.AreEqual(messageLength, q.FillWriterWithMessages(ref writer));
|
||||
AssertIsTestMessage(data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithBytes_NoopIfNoData()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(k_TestQueueCapacity, Allocator.Temp);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
Assert.AreEqual(0, q.FillWriterWithBytes(ref writer));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithBytes_WriterCapacityMoreThanLength()
|
||||
{
|
||||
var dataLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;
|
||||
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(k_TestQueueCapacity, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
Assert.AreEqual(dataLength, q.FillWriterWithBytes(ref writer));
|
||||
AssertIsTestMessage(data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithBytes_WriterCapacityLessThanLength()
|
||||
{
|
||||
var dataLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;
|
||||
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(dataLength, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
Assert.AreEqual(dataLength, q.FillWriterWithBytes(ref writer));
|
||||
AssertIsTestMessage(data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_FillWriterWithBytes_WriterCapacityEqualToLength()
|
||||
{
|
||||
var dataLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;
|
||||
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
using var data = new NativeArray<byte>(dataLength, Allocator.Temp);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var writer = new DataStreamWriter(data);
|
||||
Assert.AreEqual(dataLength, q.FillWriterWithBytes(ref writer));
|
||||
AssertIsTestMessage(data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_ConsumeLessThanLength()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
var messageLength = k_TestMessageSize + BatchedSendQueue.PerMessageOverhead;
|
||||
q.Consume(messageLength);
|
||||
Assert.AreEqual(messageLength, q.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_ConsumeExactLength()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
q.Consume(k_TestMessageSize + BatchedSendQueue.PerMessageOverhead);
|
||||
Assert.AreEqual(0, q.Length);
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BatchedSendQueue_ConsumeMoreThanLength()
|
||||
{
|
||||
using var q = new BatchedSendQueue(k_TestQueueCapacity);
|
||||
|
||||
q.PushMessage(m_TestMessage);
|
||||
|
||||
q.Consume(k_TestQueueCapacity);
|
||||
Assert.AreEqual(0, q.Length);
|
||||
Assert.True(q.IsEmpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Tests/Editor/Transports/BatchedSendQueueTests.cs.meta
Normal file
11
Tests/Editor/Transports/BatchedSendQueueTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51a68dc80bf18443180f3600eb5890d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
84
Tests/Editor/Transports/UnityTransportTests.cs
Normal file
84
Tests/Editor/Transports/UnityTransportTests.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using NUnit.Framework;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.Netcode.EditorTests
|
||||
{
|
||||
public class UnityTransportTests
|
||||
{
|
||||
// Check that starting a server doesn't immediately result in faulted tasks.
|
||||
[Test]
|
||||
public void BasicInitServer()
|
||||
{
|
||||
UnityTransport transport = new GameObject().AddComponent<UnityTransport>();
|
||||
transport.Initialize();
|
||||
|
||||
Assert.True(transport.StartServer());
|
||||
|
||||
transport.Shutdown();
|
||||
}
|
||||
|
||||
// Check that starting a client doesn't immediately result in faulted tasks.
|
||||
[Test]
|
||||
public void BasicInitClient()
|
||||
{
|
||||
UnityTransport transport = new GameObject().AddComponent<UnityTransport>();
|
||||
transport.Initialize();
|
||||
|
||||
Assert.True(transport.StartClient());
|
||||
|
||||
transport.Shutdown();
|
||||
}
|
||||
|
||||
// Check that we can't restart a server.
|
||||
[Test]
|
||||
public void NoRestartServer()
|
||||
{
|
||||
UnityTransport transport = new GameObject().AddComponent<UnityTransport>();
|
||||
transport.Initialize();
|
||||
|
||||
transport.StartServer();
|
||||
Assert.False(transport.StartServer());
|
||||
|
||||
transport.Shutdown();
|
||||
}
|
||||
|
||||
// Check that we can't restart a client.
|
||||
[Test]
|
||||
public void NoRestartClient()
|
||||
{
|
||||
UnityTransport transport = new GameObject().AddComponent<UnityTransport>();
|
||||
transport.Initialize();
|
||||
|
||||
transport.StartClient();
|
||||
Assert.False(transport.StartClient());
|
||||
|
||||
transport.Shutdown();
|
||||
}
|
||||
|
||||
// Check that we can't start both a server and client on the same transport.
|
||||
[Test]
|
||||
public void NotBothServerAndClient()
|
||||
{
|
||||
UnityTransport transport;
|
||||
|
||||
// Start server then client.
|
||||
transport = new GameObject().AddComponent<UnityTransport>();
|
||||
transport.Initialize();
|
||||
|
||||
transport.StartServer();
|
||||
Assert.False(transport.StartClient());
|
||||
|
||||
transport.Shutdown();
|
||||
|
||||
// Start client then server.
|
||||
transport = new GameObject().AddComponent<UnityTransport>();
|
||||
transport.Initialize();
|
||||
|
||||
transport.StartClient();
|
||||
Assert.False(transport.StartServer());
|
||||
|
||||
transport.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Tests/Editor/Transports/UnityTransportTests.cs.meta
Normal file
11
Tests/Editor/Transports/UnityTransportTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b0137a26ef0140f0bf5167c09eecb96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user