mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Tests: MultiplexTransportEnableTest moved to separate file
This commit is contained in:
parent
227402c6aa
commit
9b78ee82f1
@ -2,7 +2,7 @@
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.Tests.Runtime.TransportEnableTest
|
||||
namespace Mirror.Tests.Runtime
|
||||
{
|
||||
public class FallbackTransportEnableTest
|
||||
{
|
||||
@ -53,55 +53,4 @@ public void DisableShouldDisableAvailableTransport()
|
||||
Assert.That(transport2.enabled, Is.True);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MultiplexTransportEnableTest
|
||||
{
|
||||
MemoryTransport transport1;
|
||||
MemoryTransport transport2;
|
||||
MultiplexTransport transport;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
GameObject gameObject = new GameObject();
|
||||
// set inactive so that awake isn't called
|
||||
gameObject.SetActive(false);
|
||||
|
||||
transport1 = gameObject.AddComponent<MemoryTransport>();
|
||||
transport2 = gameObject.AddComponent<MemoryTransport>();
|
||||
|
||||
transport = gameObject.AddComponent<MultiplexTransport>();
|
||||
transport.transports = new[] { transport1, transport2 };
|
||||
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
GameObject.DestroyImmediate(transport.gameObject);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisableShouldDisableAllTransports()
|
||||
{
|
||||
transport.Awake();
|
||||
|
||||
// starts enabled
|
||||
Assert.That(transport1.enabled, Is.True);
|
||||
Assert.That(transport2.enabled, Is.True);
|
||||
|
||||
// disabling MultiplexTransport
|
||||
transport.enabled = false;
|
||||
Assert.That(transport1.enabled, Is.False);
|
||||
Assert.That(transport2.enabled, Is.False);
|
||||
|
||||
// enabling MultiplexTransport
|
||||
transport.enabled = true;
|
||||
Assert.That(transport1.enabled, Is.True);
|
||||
Assert.That(transport2.enabled, Is.True);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
54
Assets/Mirror/Tests/Runtime/MultiplexTransportEnableTest.cs
Normal file
54
Assets/Mirror/Tests/Runtime/MultiplexTransportEnableTest.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.Tests.Runtime
|
||||
{
|
||||
public class MultiplexTransportEnableTest
|
||||
{
|
||||
MemoryTransport transport1;
|
||||
MemoryTransport transport2;
|
||||
MultiplexTransport transport;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
GameObject gameObject = new GameObject();
|
||||
// set inactive so that awake isn't called
|
||||
gameObject.SetActive(false);
|
||||
|
||||
transport1 = gameObject.AddComponent<MemoryTransport>();
|
||||
transport2 = gameObject.AddComponent<MemoryTransport>();
|
||||
|
||||
transport = gameObject.AddComponent<MultiplexTransport>();
|
||||
transport.transports = new[] { transport1, transport2 };
|
||||
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
GameObject.DestroyImmediate(transport.gameObject);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisableShouldDisableAllTransports()
|
||||
{
|
||||
transport.Awake();
|
||||
|
||||
// starts enabled
|
||||
Assert.That(transport1.enabled, Is.True);
|
||||
Assert.That(transport2.enabled, Is.True);
|
||||
|
||||
// disabling MultiplexTransport
|
||||
transport.enabled = false;
|
||||
Assert.That(transport1.enabled, Is.False);
|
||||
Assert.That(transport2.enabled, Is.False);
|
||||
|
||||
// enabling MultiplexTransport
|
||||
transport.enabled = true;
|
||||
Assert.That(transport1.enabled, Is.True);
|
||||
Assert.That(transport2.enabled, Is.True);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06352e90eaaa45b09d12e717dd0cae7c
|
||||
timeCreated: 1622028545
|
Loading…
Reference in New Issue
Block a user