Пример #1
0
        public void SubscribeWithAttributeTest()
        {
            // Arrange
            var subject = new TestSubject();

            TinyPubSubLib.TinyPubSub.Register(subject);

            // Act
            TinyPubSubLib.TinyPubSub.Publish("test");

            // Assert
            Assert.True(subject.IsSuccessful);
        }
Пример #2
0
        public async Task SubscribeAsyncWithAttributeTest()
        {
            // Arrange
            var subject = new TestSubject();

            TinyPubSubLib.TinyPubSub.Register(subject);

            // Act
            TinyPubSubLib.TinyPubSub.Publish("test-async");
            await Task.Delay(100);

            // Assert
            Assert.True(subject.IsSuccessful);
        }
Пример #3
0
        public void SubscribeWithWrongParameterTest()
        {
            // Arrange
            var subject = new TestSubject();

            TinyPubSubLib.TinyPubSub.Register(subject);

            // Act
            var data = new BadTestType();

            TinyPubSubLib.TinyPubSub.Publish("test-with-bad-arguments", data, onError: (Exception arg1, ISubscription arg2) => subject.IsSuccessful = true);

            // Assert
            Assert.True(subject.IsSuccessful);
        }
Пример #4
0
        public void SubscribeWithParameterTest()
        {
            // Arrange
            var subject = new TestSubject();

            TinyPubSubLib.TinyPubSub.Register(subject);

            // Act
            var data = new TestType()
            {
                DuckLength = 42
            };

            TinyPubSubLib.TinyPubSub.Publish("test-with-arguments", data, onError: (Exception arg1, ISubscription arg2) => Console.WriteLine($"Exception occured: {arg1.ToString()}"));

            // Assert
            Assert.True(subject.IsSuccessful);
        }