Skip to content

Commit 1865157

Browse files
update + style
Just keeping the established pattern of using "nameof" within a string. Also added the NetworkTransform's NetworkBehaviourId value as opposed to hard coding the value. (minor tweaks)
1 parent 7d49662 commit 1865157

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformErrorTests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,28 @@ protected override void OnServerAndClientsCreated()
9898
base.OnServerAndClientsCreated();
9999
}
100100

101-
101+
/// <summary>
102+
/// Validates the fix where <see cref="NetworkTransformMessage"/> would throw an exception
103+
/// if a user sets a <see cref="GameObject"/> with one or more <see cref="NetworkBehaviour"/> components
104+
/// to inactive.
105+
/// </summary>
102106
[UnityTest]
103107
public IEnumerator DisabledGameObjectErrorTest()
104108
{
105109
var instance = SpawnObject(m_AuthorityPrefab, m_ServerNetworkManager);
106110
var networkObjectInstance = instance.GetComponent<NetworkObject>();
107-
var networkTransformInstance = instance.GetComponent<NetworkTransform>();
111+
var networkTransformInstance = instance.GetComponentInChildren<NetworkTransform>();
108112

109113
yield return WaitForConditionOrTimeOut(() => ObjectSpawnedOnAllClients(networkObjectInstance.NetworkObjectId));
110114
AssertOnTimeout("Timed out waiting for object to spawn!");
111115

112-
LogAssert.Expect(LogType.Error, $"[Netcode] {nameof(NetworkBehaviour)} index {networkTransformInstance.NetworkBehaviourId} was out of bounds for NonAuthorityPrefab(Clone). " +
113-
$"{nameof(NetworkBehaviour)}s must be the same, and in the same order, between server and client.");
114-
LogAssert.Expect(LogType.Error, $"[{nameof(NetworkTransformMessage)}][Invalid] Targeted {nameof(NetworkTransform)}, {nameof(NetworkBehaviour.NetworkBehaviourId)} " +
116+
var errorMessage = $"[Netcode] {nameof(NetworkBehaviour)} index {networkTransformInstance.NetworkBehaviourId} was out of bounds for {m_NonAuthorityPrefab.name}(Clone). " +
117+
$"{nameof(NetworkBehaviour)}s must be the same, and in the same order, between server and client.";
118+
LogAssert.Expect(LogType.Error, errorMessage);
119+
errorMessage = $"[{nameof(NetworkTransformMessage)}][Invalid] Targeted {nameof(NetworkTransform)}, {nameof(NetworkBehaviour.NetworkBehaviourId)} " +
115120
$"({networkTransformInstance.NetworkBehaviourId}), does not exist! Make sure you are not spawning {nameof(NetworkObject)}s with disabled {nameof(GameObject)}s that have " +
116-
$"{nameof(NetworkBehaviour)} components on them.");
121+
$"{nameof(NetworkBehaviour)} components on them.";
122+
LogAssert.Expect(LogType.Error, errorMessage);
117123

118124
yield return new WaitForSeconds(0.3f);
119125
}

0 commit comments

Comments
 (0)