static void Main(string[] args)
        {
            var bookingStream   = new BookingStream();
            var bookingConsumer = new BookingConsumer(bookingStream, Console.WriteLine);

            bookingStream.Subscribe("Subscriber1", (m) => Console.WriteLine($"Subscriber1 Message : {m.Message}"));
            bookingStream.Subscribe("Subscriber2", (m) => Console.WriteLine($"Subscriber2 Message Formatted : {m.Message.Substring(0, 2)}"));

            bookingConsumer.Listen();

            // WithObserver();
            //// WithoutRxExtension();
            //// WithLambda();
            //// WithExtension();
            //// WithReplaySubject();
            //// WithBehaviourSubject();
            //// WithAsyncSubject();
            //WithObservable();
            //// Factories();
            //// Blocking();
            //// NonBlocking();
            ////OperatorsReturn();

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            var bookingStrem    = new BookingStream();
            var bookingConsumer = new BookingConsumer(bookingStrem);

            bookingStrem.Subscribe("sub1", (m) => Console.WriteLine($"sub1 message: {m.Message}"));
            //bookingStrem.Subscribe("sub2", (m) => Console.WriteLine($"sub2 message: {m.Message}"));

            bookingConsumer.Listen();
        }
示例#3
0
        public void Test_Empty_Message()
        {
            var bookingStream = new BookingStream();

            var bookingMessage = default(BookingMessage);

            bookingStream.Subscribe("Test_Subscriber_2", (m) => bookingMessage = m);

            bookingStream.Publish(new BookingMessage {
                Message = ""
            });

            Assert.Null(bookingMessage);
        }
示例#4
0
        public void Test_Valid_Message()
        {
            var bookingStream = new BookingStream();

            var bookingMessage = default(BookingMessage);

            bookingStream.Subscribe("Test_Subscriber_1", (m) => bookingMessage = m);

            bookingStream.Publish(new BookingMessage {
                Message = "Test_Message"
            });

            Assert.Equal("Test_Message", bookingMessage.Message);
        }