Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public void EventLoadTest()
        {
            var botBits = new BotBitsClient();

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

            Assert.IsTrue(
                TestEvent
                .Of(botBits)
                .Contains(this.OnTest));
        }
Exemplo n.º 4
0
        public void EventLoadStaticTest()
        {
            var botBits = new BotBitsClient();

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

            Assert.IsTrue(
                TestEvent
                .Of(botBits)
                .Contains(OnStaticTest));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }