示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        public void EventLoadTest()
        {
            var botBits = new BotBitsClient();

            EventLoader
            .Of(botBits)
            .Load(this);

            Assert.IsTrue(
                TestEvent
                .Of(botBits)
                .Contains(this.OnTest));
        }
示例#4
0
        public void EventLoadStaticTest()
        {
            var botBits = new BotBitsClient();

            EventLoader
            .Of(botBits)
            .LoadStatic <EventLoaderTests>();

            Assert.IsTrue(
                TestEvent
                .Of(botBits)
                .Contains(OnStaticTest));
        }
示例#5
0
        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));
        }
示例#6
0
        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);
        }