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 PostEventTest() { var eventBus = new EventBus(); var e = new SampleEvent { Data = "Hello World" }; var e2 = new AnotherSampleEvent { Data = "Hello World 2" }; eventBus.Subscribe <SampleEvent>(OnSampleEvent); Assert.IsFalse(m_EventReceived); eventBus.Post(e); Assert.IsTrue(m_EventReceived); m_EventReceived = false; eventBus.Post(e2); Assert.IsFalse(m_EventReceived); eventBus.Unsubscribe <SampleEvent>(OnSampleEvent); eventBus.Post(e); Assert.IsFalse(m_EventReceived); }