public void UnbindAllTest() { var botBits = new BotBitsClient(); var callback = new EventRaiseHandler <TestEvent>(delegate { }); TestEvent .Of(botBits) .Bind(callback); TestEvent .Of(botBits) .Bind(callback); TestEvent .Of(botBits) .Bind(callback, EventPriority.High); TestEvent .Of(botBits) .UnbindAll(); Assert.AreEqual(0, TestEvent .Of(botBits) .Count); }
public void PriorityTest() { var last = EventPriority.Highest; var check = new Action <EventPriority>(i => { if (last > i) { Assert.Fail("Wrong order! Failed at: " + i); } last = i; }); var lowest = new EventRaiseHandler <TestEvent>(e => check(EventPriority.Lowest)); var low = new EventRaiseHandler <TestEvent>(e => check(EventPriority.Low)); var normal = new EventRaiseHandler <TestEvent>(e => check(EventPriority.Normal)); var high = new EventRaiseHandler <TestEvent>(e => check(EventPriority.High)); var highest = new EventRaiseHandler <TestEvent>(e => check(EventPriority.Highest)); var botBits = new BotBitsClient(); TestEvent.Of(botBits).Bind(highest, EventPriority.Highest); TestEvent.Of(botBits).Bind(lowest, EventPriority.Lowest); TestEvent.Of(botBits).Bind(high, EventPriority.High); TestEvent.Of(botBits).Bind(low, EventPriority.Low); TestEvent.Of(botBits).Bind(normal); new TestEvent().RaiseIn(botBits); }
public void EventLoadTest() { var botBits = new BotBitsClient(); EventLoader .Of(botBits) .Load(this); Assert.IsTrue( TestEvent .Of(botBits) .Contains(this.OnTest)); }
public void EventLoadStaticTest() { var botBits = new BotBitsClient(); EventLoader .Of(botBits) .LoadStatic <EventLoaderTests>(); Assert.IsTrue( TestEvent .Of(botBits) .Contains(OnStaticTest)); }
public void BindTest() { var botBits = new BotBitsClient(); var callback = new EventRaiseHandler <TestEvent>(delegate { }); TestEvent .Of(botBits) .Bind(callback); Assert.IsTrue( TestEvent .Of(botBits) .Contains(callback)); }
public void RaiseTest() { var isCalled = false; var callback = new EventRaiseHandler <TestEvent>(e => isCalled = true); var botBits = new BotBitsClient(); TestEvent .Of(botBits) .Bind(callback); new TestEvent() .RaiseIn(botBits); Assert.IsTrue(isCalled); }