public SignalHub(ISceneDirector sceneDirector)
        {
            globalScopeSignalRegistry = new AltoSignalRegistry();
            sceneScopeSignalRegistry  = new AltoSignalRegistry();

            sceneDirector.sceneLoading += OnSceneLoading;
        }
        public void TestGetOrCreate()
        {
            var registry = new AltoSignalRegistry();
            var signalA1 = registry.GetOrCreate <Signal_A>();
            var signalA2 = registry.GetOrCreate <Signal_A>();
            var signalB1 = registry.GetOrCreate <Signal_B>();

            Assert.That(signalA1, Is.InstanceOf <Signal_A>());
            Assert.That(signalA2, Is.InstanceOf <Signal_A>());
            Assert.That(signalB1, Is.InstanceOf <Signal_B>());
            Assert.That(signalA1, Is.SameAs(signalA2));
        }
        public void TestEmitWith1Arg()
        {
            int          result = 0;
            Action <int> action = (int val) => { result += val; };

            var registry = new AltoSignalRegistry();

            registry.GetOrCreate <Signal1>().Connect(action);
            Assert.That(result, Is.EqualTo(0));

            registry.GetOrCreate <Signal1>().Emit(123);
            Assert.That(result, Is.EqualTo(123));
        }
        public void TestEmit()
        {
            int    result = 0;
            Action action = () => { result += 10; };

            var registry = new AltoSignalRegistry();

            registry.GetOrCreate <Signal_A>().Connect(action);
            Assert.That(result, Is.EqualTo(0));

            registry.GetOrCreate <Signal_A>().Emit();
            Assert.That(result, Is.EqualTo(10));
        }
        public void TestClear()
        {
            var registry = new AltoSignalRegistry();

            Assert.That(registry.Count, Is.EqualTo(0));

            var signalA1 = registry.GetOrCreate <Signal_A>();
            var signalA2 = registry.GetOrCreate <Signal_A>();
            var signalB1 = registry.GetOrCreate <Signal_B>();

            Assert.That(registry.Count, Is.EqualTo(2));

            registry.Clear();
            Assert.That(registry.Count, Is.EqualTo(0));
        }
        public void TestEmitWith2Args()
        {
            string seq    = "";
            int    result = 0;
            Action <string, int> action = (string str, int val) => {
                seq    += str;
                result += val;
            };

            var registry = new AltoSignalRegistry();

            registry.GetOrCreate <Signal2>().Connect(action);
            Assert.That(result, Is.EqualTo(0));

            registry.GetOrCreate <Signal2>().Emit("hoge", 456);
            Assert.That(seq, Is.EqualTo("hoge"));
            Assert.That(result, Is.EqualTo(456));
        }