File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1- using UnityEngine ;
1+ using System ;
2+ using TNRD . Events ;
3+ using UnityEngine ;
24
35public class DummyBehaviour : MonoBehaviour
46{
@@ -9,6 +11,14 @@ public class DummyBehaviour : MonoBehaviour
911 public int Arg1 { get ; private set ; }
1012 public int Arg2 { get ; private set ; }
1113
14+ private SafeEvent onExposedEvent ;
15+
16+ public event Action OnExposedEvent
17+ {
18+ add => onExposedEvent . Subscribe ( value ) ;
19+ remove => onExposedEvent . Unsubscribe ( value ) ;
20+ }
21+
1222 public void Dummy ( )
1323 {
1424 Invoked = true ;
@@ -24,4 +34,9 @@ public void Dummy(int arg1, int arg2)
2434 Arg1 = arg1 ;
2535 Arg2 = arg2 ;
2636 }
37+
38+ public void DispatchOnExposedEvent ( )
39+ {
40+ onExposedEvent . Invoke ( ) ;
41+ }
2742}
Original file line number Diff line number Diff line change @@ -71,4 +71,25 @@ public IEnumerator Invoke_On_Destroyed_GameObject()
7171 Assert . IsNotNull ( exception ) ;
7272 Object . Destroy ( holder ) ;
7373 }
74+
75+ [ UnityTest ]
76+ public IEnumerator Dispatch_Exposed_Action ( )
77+ {
78+ var holder = new GameObject ( ) ;
79+ var dummyBehaviour = holder . AddComponent < DummyBehaviour > ( ) ;
80+ yield return null ;
81+
82+ bool invoked = false ;
83+
84+ dummyBehaviour . OnExposedEvent += ( ) =>
85+ {
86+ invoked = true ;
87+ } ;
88+
89+ Assert . IsFalse ( invoked ) ;
90+ dummyBehaviour . DispatchOnExposedEvent ( ) ;
91+ Assert . IsTrue ( invoked ) ;
92+
93+ Object . Destroy ( holder ) ;
94+ }
7495}
You can’t perform that action at this time.
0 commit comments