Пример #1
0
        public void SubscribeWithEventArguments()
        {
            // Arrange
            var testsuccessful = 0;
            var tstType        = new TestEventType();
            var channel        = Guid.NewGuid().ToString();

            TinyPubSubLib.TinyPubSub.Subscribe <TestEventType>(null, channel, (TestEventType x) =>
            {
                testsuccessful = 3;
            });

            TinyPubSubLib.TinyPubSub.Subscribe <TestEventType>(null, channel, (TestEventType x, TinyPubSubLib.TinyEventArgs evtargs) =>
            {
                evtargs.HaltExecution = true;
            });

            TinyPubSubLib.TinyPubSub.Subscribe <TestEventType>(null, channel, (TestEventType x) =>
            {
                testsuccessful = 4;
            });

            // Act
            var ret = TinyPubSubLib.TinyPubSub.PublishControlled(channel, tstType);

            // Assert
            Assert.True(testsuccessful == 3 && ret.Handled == true);
        }
Пример #2
0
        public void SubscribeWithTypeTest()
        {
            // Arrange
            var testsuccessful = false;
            var tstType        = new TestEventType();
            var channel        = Guid.NewGuid().ToString();

            TinyPubSubLib.TinyPubSub.Subscribe <TestEventType>(channel, (x) => testsuccessful = (x.Sklep == 5));

            // Act
            TinyPubSubLib.TinyPubSub.Publish(channel, tstType);

            // Assert
            Assert.True(testsuccessful);
        }