mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
refactor: use NUnit idiomatic constraints
Why? Suppose you have this: ```cs Assert.That(manager.networkAddress == "localhost"); ``` and suppose it fails, it will give you: "Expected True, but got False" which does not give you anything useful. Suppose you have this instead: ```cs Assert.That(manager.networkAddress, Is.EqualTo("localhost")); ``` Suppose it fails, now it will give you a much more useful error message: "Expected 'localhost' but got 'xxxxx'" It makes debugging tests a lot easier.
This commit is contained in:
parent
fb9c55bf6e
commit
108c83a43a
@ -25,35 +25,35 @@ public void TearDownNetworkManager()
|
|||||||
[Test]
|
[Test]
|
||||||
public void VariableTest()
|
public void VariableTest()
|
||||||
{
|
{
|
||||||
Assert.That(manager.dontDestroyOnLoad == true);
|
Assert.That(manager.dontDestroyOnLoad, Is.True);
|
||||||
Assert.That(manager.runInBackground == true);
|
Assert.That(manager.runInBackground, Is.True);
|
||||||
Assert.That(manager.startOnHeadless == true);
|
Assert.That(manager.startOnHeadless, Is.True);
|
||||||
Assert.That(manager.showDebugMessages == false);
|
Assert.That(manager.showDebugMessages, Is.False);
|
||||||
Assert.That(manager.serverTickRate == 30);
|
Assert.That(manager.serverTickRate, Is.EqualTo(30));
|
||||||
Assert.That(manager.offlineScene == "");
|
Assert.That(manager.offlineScene, Is.Empty);
|
||||||
Assert.That(manager.networkAddress == "localhost");
|
Assert.That(manager.networkAddress, Is.EqualTo("localhost"));
|
||||||
Assert.That(manager.maxConnections == 4);
|
Assert.That(manager.maxConnections, Is.EqualTo(4));
|
||||||
Assert.That(manager.autoCreatePlayer == true);
|
Assert.That(manager.autoCreatePlayer, Is.True);
|
||||||
Assert.That(manager.spawnPrefabs.Count == 0);
|
Assert.That(manager.spawnPrefabs, Is.Empty);
|
||||||
Assert.That(manager.numPlayers == 0);
|
Assert.That(manager.numPlayers, Is.Zero);
|
||||||
Assert.That(manager.isNetworkActive == false);
|
Assert.That(manager.isNetworkActive, Is.False);
|
||||||
|
|
||||||
Assert.That(NetworkManager.networkSceneName == "");
|
Assert.That(NetworkManager.networkSceneName, Is.Empty);
|
||||||
Assert.That(NetworkManager.startPositionIndex == 0);
|
Assert.That(NetworkManager.startPositionIndex, Is.Zero);
|
||||||
Assert.That(NetworkManager.startPositions.Count == 0);
|
Assert.That(NetworkManager.startPositions, Is.Empty);
|
||||||
Assert.That(NetworkManager.isHeadless == false);
|
Assert.That(NetworkManager.isHeadless, Is.False);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void StartServerTest()
|
public void StartServerTest()
|
||||||
{
|
{
|
||||||
Assert.That(NetworkServer.active == false);
|
Assert.That(NetworkServer.active , Is.False);
|
||||||
|
|
||||||
manager.StartServer();
|
manager.StartServer();
|
||||||
|
|
||||||
Assert.That(manager.isNetworkActive == true);
|
Assert.That(manager.isNetworkActive , Is.True);
|
||||||
Assert.That(manager.mode == NetworkManagerMode.ServerOnly);
|
Assert.That(manager.mode == NetworkManagerMode.ServerOnly);
|
||||||
Assert.That(NetworkServer.active == true);
|
Assert.That(NetworkServer.active , Is.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -62,7 +62,7 @@ public void StopServerTest()
|
|||||||
manager.StartServer();
|
manager.StartServer();
|
||||||
manager.StopServer();
|
manager.StopServer();
|
||||||
|
|
||||||
Assert.That(manager.isNetworkActive == false);
|
Assert.That(manager.isNetworkActive , Is.False);
|
||||||
Assert.That(manager.mode == NetworkManagerMode.Offline);
|
Assert.That(manager.mode == NetworkManagerMode.Offline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public void StartClientTest()
|
|||||||
{
|
{
|
||||||
manager.StartClient();
|
manager.StartClient();
|
||||||
|
|
||||||
Assert.That(manager.isNetworkActive == true);
|
Assert.That(manager.isNetworkActive , Is.True);
|
||||||
Assert.That(manager.mode == NetworkManagerMode.ClientOnly);
|
Assert.That(manager.mode == NetworkManagerMode.ClientOnly);
|
||||||
|
|
||||||
manager.StopClient();
|
manager.StopClient();
|
||||||
@ -83,7 +83,7 @@ public void StopClientTest()
|
|||||||
manager.StartClient();
|
manager.StartClient();
|
||||||
manager.StopClient();
|
manager.StopClient();
|
||||||
|
|
||||||
Assert.That(manager.isNetworkActive == false);
|
Assert.That(manager.isNetworkActive , Is.False);
|
||||||
Assert.That(manager.mode == NetworkManagerMode.Offline);
|
Assert.That(manager.mode == NetworkManagerMode.Offline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,20 +93,20 @@ public void ShutdownTest()
|
|||||||
manager.StartClient();
|
manager.StartClient();
|
||||||
NetworkManager.Shutdown();
|
NetworkManager.Shutdown();
|
||||||
|
|
||||||
Assert.That(NetworkManager.startPositions.Count == 0);
|
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
|
||||||
Assert.That(NetworkManager.startPositionIndex == 0);
|
Assert.That(NetworkManager.startPositionIndex , Is.Zero);
|
||||||
Assert.That(NetworkManager.startPositionIndex == 0);
|
Assert.That(NetworkManager.startPositionIndex , Is.Zero);
|
||||||
Assert.That(NetworkManager.singleton == null);
|
Assert.That(NetworkManager.singleton , Is.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void RegisterStartPositionTest()
|
public void RegisterStartPositionTest()
|
||||||
{
|
{
|
||||||
Assert.That(NetworkManager.startPositions.Count == 0);
|
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
|
||||||
|
|
||||||
NetworkManager.RegisterStartPosition(gameObject.transform);
|
NetworkManager.RegisterStartPosition(gameObject.transform);
|
||||||
Assert.That(NetworkManager.startPositions.Count == 1);
|
Assert.That(NetworkManager.startPositions.Count , Is.EqualTo(1));
|
||||||
Assert.That(NetworkManager.startPositions.Contains(gameObject.transform));
|
Assert.That(NetworkManager.startPositions, Has.Member(gameObject.transform));
|
||||||
|
|
||||||
NetworkManager.UnRegisterStartPosition(gameObject.transform);
|
NetworkManager.UnRegisterStartPosition(gameObject.transform);
|
||||||
}
|
}
|
||||||
@ -114,26 +114,26 @@ public void RegisterStartPositionTest()
|
|||||||
[Test]
|
[Test]
|
||||||
public void UnRegisterStartPositionTest()
|
public void UnRegisterStartPositionTest()
|
||||||
{
|
{
|
||||||
Assert.That(NetworkManager.startPositions.Count == 0);
|
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
|
||||||
|
|
||||||
NetworkManager.RegisterStartPosition(gameObject.transform);
|
NetworkManager.RegisterStartPosition(gameObject.transform);
|
||||||
Assert.That(NetworkManager.startPositions.Count == 1);
|
Assert.That(NetworkManager.startPositions.Count , Is.EqualTo(1));
|
||||||
Assert.That(NetworkManager.startPositions.Contains(gameObject.transform));
|
Assert.That(NetworkManager.startPositions, Has.Member(gameObject.transform));
|
||||||
|
|
||||||
NetworkManager.UnRegisterStartPosition(gameObject.transform);
|
NetworkManager.UnRegisterStartPosition(gameObject.transform);
|
||||||
Assert.That(NetworkManager.startPositions.Count == 0);
|
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetStartPositionTest()
|
public void GetStartPositionTest()
|
||||||
{
|
{
|
||||||
Assert.That(NetworkManager.startPositions.Count == 0);
|
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
|
||||||
|
|
||||||
NetworkManager.RegisterStartPosition(gameObject.transform);
|
NetworkManager.RegisterStartPosition(gameObject.transform);
|
||||||
Assert.That(NetworkManager.startPositions.Count == 1);
|
Assert.That(NetworkManager.startPositions.Count , Is.EqualTo(1));
|
||||||
Assert.That(NetworkManager.startPositions.Contains(gameObject.transform));
|
Assert.That(NetworkManager.startPositions, Has.Member(gameObject.transform));
|
||||||
|
|
||||||
Assert.That(manager.GetStartPosition() == gameObject.transform);
|
Assert.That(manager.GetStartPosition(), Is.SameAs(gameObject.transform));
|
||||||
|
|
||||||
NetworkManager.UnRegisterStartPosition(gameObject.transform);
|
NetworkManager.UnRegisterStartPosition(gameObject.transform);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user