Exemplo n.º 1
0
        public void Subscribe_Disposed_Throws()
        {
            // arrange
            var             bus     = new TukBus();
            Action <IEvent> handler = args => { };

            // act
            using (bus) { }
            bus.Subscribe <FakeEvent1>(handler);
        }
Exemplo n.º 2
0
        public void Dispose_AlreadyDisposed_Throws()
        {
            // arrange
            var bus = new TukBus();

            // act
            using (bus) { }
            using (bus) { }

            // assert
            Assert.Fail();
        }
Exemplo n.º 3
0
        public void Publish_Disposed_Throws()
        {
            // arrange
            var bus = new TukBus();

            // act
            using (bus) { }
            bus.Publish(new FakeEvent1());

            // assert
            Assert.Fail();
        }
Exemplo n.º 4
0
        private static void Main(string[] args)
        {
            var bus     = new TukBus();
            var session = bus.Subscribe <MultipleOfFifteenEvent>(HandleEvent);

            Console.WriteLine("Outputting multiples of 15 between 1 and 10000...");
            Run(bus);

            Console.ReadLine();

            // you could put this in a using statement, but understand that the notification queue may
            // not be finished yet. This is perfectly fine in eventual consistency situations
            bus.Dispose();
        }
Exemplo n.º 5
0
        public void Dispose_Disposes()
        {
            // arrange
            var             bus       = new TukBus();
            const string    expected1 = "One";
            const string    expected2 = "Two";
            var             actual1   = string.Empty;
            var             actual2   = string.Empty;
            Action <IEvent> handler1  = args => { actual1 = expected1; };
            Action <IEvent> handler2  = args => { actual2 = expected2; };

            bus.Subscribe <FakeEvent1>(handler1);
            bus.Subscribe <FakeEvent2>(handler2);

            // act
            using (bus) { }

            // assert
            Assert.IsTrue(bus.IsDisposed);
        }
Exemplo n.º 6
0
 public void Init()
 {
     _bus = new TukBus();
     _bus.Clear();
 }