1
+ using System . Text . RegularExpressions ;
1
2
using NUnit . Framework ;
2
3
using UnityEngine ;
3
4
using UnityEngine . TestTools ;
@@ -31,19 +32,17 @@ public void NetworkManagerOverrideTest()
31
32
}
32
33
33
34
[ Test ]
34
- public void GetBehaviourIndexNone ( )
35
+ [ TestCase ( 0 ) ]
36
+ [ TestCase ( 1 ) ]
37
+ [ TestCase ( 2 ) ]
38
+ public void GetBehaviourIndexNone ( int index )
35
39
{
36
40
var gameObject = new GameObject ( nameof ( GetBehaviourIndexNone ) ) ;
37
41
var networkObject = gameObject . AddComponent < NetworkObject > ( ) ;
38
42
39
- // TODO: Maybe not hardcode message?
40
- LogAssert . Expect ( LogType . Error , $ "[Netcode] Behaviour index was out of bounds. Did you mess up the order of your { nameof ( NetworkBehaviour ) } s?") ;
41
- LogAssert . Expect ( LogType . Error , $ "[Netcode] Behaviour index was out of bounds. Did you mess up the order of your { nameof ( NetworkBehaviour ) } s?") ;
42
- LogAssert . Expect ( LogType . Error , $ "[Netcode] Behaviour index was out of bounds. Did you mess up the order of your { nameof ( NetworkBehaviour ) } s?") ;
43
+ LogAssert . Expect ( LogType . Error , new Regex ( ".*out of bounds.*" ) ) ;
43
44
44
- Assert . That ( networkObject . GetNetworkBehaviourAtOrderIndex ( 0 ) , Is . Null ) ;
45
- Assert . That ( networkObject . GetNetworkBehaviourAtOrderIndex ( 1 ) , Is . Null ) ;
46
- Assert . That ( networkObject . GetNetworkBehaviourAtOrderIndex ( 2 ) , Is . Null ) ;
45
+ Assert . That ( networkObject . GetNetworkBehaviourAtOrderIndex ( ( ushort ) index ) , Is . Null ) ;
47
46
48
47
// Cleanup
49
48
Object . DestroyImmediate ( gameObject ) ;
@@ -56,13 +55,10 @@ public void GetBehaviourIndexOne()
56
55
var networkObject = gameObject . AddComponent < NetworkObject > ( ) ;
57
56
var networkBehaviour = gameObject . AddComponent < EmptyNetworkBehaviour > ( ) ;
58
57
59
- // TODO: Maybe not hardcode message?
60
- LogAssert . Expect ( LogType . Error , $ "[Netcode] Behaviour index was out of bounds. Did you mess up the order of your { nameof ( NetworkBehaviour ) } s?") ;
61
- LogAssert . Expect ( LogType . Error , $ "[Netcode] Behaviour index was out of bounds. Did you mess up the order of your { nameof ( NetworkBehaviour ) } s?") ;
58
+ LogAssert . Expect ( LogType . Error , new Regex ( ".*out of bounds.*" ) ) ;
62
59
63
60
Assert . That ( networkObject . GetNetworkBehaviourAtOrderIndex ( 0 ) , Is . EqualTo ( networkBehaviour ) ) ;
64
61
Assert . That ( networkObject . GetNetworkBehaviourAtOrderIndex ( 1 ) , Is . Null ) ;
65
- Assert . That ( networkObject . GetNetworkBehaviourAtOrderIndex ( 2 ) , Is . Null ) ;
66
62
67
63
// Cleanup
68
64
Object . DestroyImmediate ( gameObject ) ;
0 commit comments