public void StaticBusTest() { var e = new SampleEvent { Data = "Hello World" }; var e2 = new AnotherSampleEvent { Data = "Hello World 2" }; StaticBus <SampleEvent> .Subscribe(OnSampleEvent); Assert.IsFalse(m_EventReceived); StaticBus <SampleEvent> .Post(e); Assert.IsTrue(m_EventReceived); m_EventReceived = false; StaticBus <AnotherSampleEvent> .Post(e2); Assert.IsFalse(m_EventReceived); StaticBus <SampleEvent> .Unsubscribe(OnSampleEvent); StaticBus <SampleEvent> .Post(e); Assert.IsFalse(m_EventReceived); }
public void TestEventBusWithPoolableEvent() { var e = SamplePooledEvent.GetPooled("Hello World"); StaticBus <SamplePooledEvent> .Subscribe(OnSampleEvent); StaticBus <SamplePooledEvent> .Post(e); SamplePooledEvent.Release(e); Assert.IsTrue(m_EventReceived); m_EventReceived = false; using (SamplePooledEvent.GetPoolable("Hello World", out var evt)) { StaticBus <SamplePooledEvent> .Post(e); } Assert.IsTrue(m_EventReceived); }