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(); 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(); 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(); 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(); 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(); transport.Initialize(); transport.StartServer(); Assert.False(transport.StartClient()); transport.Shutdown(); // Start client then server. transport = new GameObject().AddComponent(); transport.Initialize(); transport.StartClient(); Assert.False(transport.StartServer()); transport.Shutdown(); } } }