Initial Commit

This commit is contained in:
Sebastian Cabrera 2021-08-02 05:44:37 -04:00
parent 53eb92e9af
commit 270ab7d11f
15341 changed files with 700234 additions and 0 deletions

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e6aab111d2a894a7e836bdd742e248d9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,72 @@
using System;
using MLAPI;
using MLAPI.Configuration;
using MLAPI.Transports;
using NUnit.Framework;
using UnityEngine;
using MLAPI.Transports.UNET;
using UnityEngine.Networking;
public class TransportTest : MonoBehaviour
{
// hack, remove any NetworkObject's from the scene to avoid spawning scene objects
// which themselves might not be able initialize themselves properly
private void ForceNetworkObjectShutdown()
{
NetworkObject[] networkObjects = FindObjectsOfType<NetworkObject>();
for (int i = 0; i < networkObjects.Length; i++)
{
DestroyImmediate(networkObjects[i]);
}
}
// A Test behaves as an ordinary method
[Test]
public void UNetCustomChannelRegistrationTest()
{
ForceNetworkObjectShutdown();
GameObject o = new GameObject();
NetworkManager nm = (NetworkManager)o.AddComponent(typeof(NetworkManager));
nm.SetSingleton();
nm.NetworkConfig = new NetworkConfig();
UNetTransport ut = (UNetTransport)o.AddComponent(typeof(UNetTransport));
ut.ServerListenPort = 7777;
nm.NetworkConfig.NetworkTransport = ut;
byte CustomChannel = 0;
// test 1: add a legit channel.
ut.Channels.Add(new UNetChannel { Id = NetworkChannel.ChannelUnused + CustomChannel, Type = QosType.Unreliable });
try
{
nm.StartServer();
}
catch
{
Assert.Fail("The UNet transport won't allow registration of a legit user channel");
}
nm.StopServer();
nm.Shutdown();
ut.Channels.Clear();
// test 2: add a bogus channel (one that intersects with the MLAPI built-in ones.) Expect failure
ut.Channels.Add(new UNetChannel { Id = NetworkChannel.Internal, Type = QosType.Unreliable });
try
{
nm.StartServer();
Assert.Fail("The UNet transport allowed registration of an MLAPI-reserved channel");
}
catch (Exception ex)
{
Debug.Log(ex.Message);
}
nm.StopServer();
nm.Shutdown();
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f94b11ceafb6c426aa67067ec95539ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,24 @@
{
"name": "Unity.Multiplayer.MLAPI.Transports.EditorTests",
"rootNamespace": "",
"references": [
"Unity.Multiplayer.MLAPI.Runtime",
"UnityEngine.TestRunner",
"UnityEditor.TestRunner"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cf3c8d3561be742cc889cc4e329fe386
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: