diff --git a/Assets/Mirror/Tests/MultiplexTest.cs b/Assets/Mirror/Tests/MultiplexTest.cs index b2aeba32e..6aaea1711 100644 --- a/Assets/Mirror/Tests/MultiplexTest.cs +++ b/Assets/Mirror/Tests/MultiplexTest.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using NSubstitute; using NUnit.Framework; @@ -57,5 +58,40 @@ public void TestConnect() transport1.DidNotReceive().ClientConnect(Arg.Any()); transport2.Received().ClientConnect("some.server.com"); } + + // A Test behaves as an ordinary method + [Test] + public void TestConnectFirstUri() + { + Uri uri = new Uri("tcp://some.server.com"); + + transport1.Available().Returns(true); + transport2.Available().Returns(true); + + transport.ClientConnect(uri); + transport1.Received().ClientConnect(uri); + transport2.DidNotReceive().ClientConnect(uri); + } + + + // A Test behaves as an ordinary method + [Test] + public void TestConnectSecondUri() + { + Uri uri = new Uri("ws://some.server.com"); + + transport1.Available().Returns(true); + + // first transport does not support websocket + transport1 + .When(x => x.ClientConnect(uri)) + .Do(x => { throw new ArgumentException("Scheme not supported"); }); + + transport2.Available().Returns(true); + + transport.ClientConnect(uri); + transport2.Received().ClientConnect(uri); + } + } }