public void RaiseSwallowsExceptionRaisedByHandlerButCallsAllOtherHandlers()
        {
            bool firstCall = false;
            bool secondCall = false;
            bool thirdCall = false;

            OneThirstyDude dude = new OneThirstyDude();
            Soda bru = new Soda();
            bru.Pop += (sender, soda) => firstCall = true;
			bru.Pop += (sender, soda) => { secondCall = true; throw new Exception(); };
			bru.Pop += (sender, soda) => { thirdCall = true; };

            DefensiveEventRaiser eventRaiser = new DefensiveEventRaiser();

            IEventExceptionsCollector exceptions = bru.OnPop( "Iron Brew", eventRaiser );

            Assert.AreEqual(1, exceptions.Exceptions.Count);
            Assert.IsTrue(firstCall);
            Assert.IsTrue(secondCall);
            Assert.IsTrue(thirdCall);
        }
Exemple #2
0
        public void RaiseSwallowsExceptionRaisedByHandlerButCallsAllOtherHandlers()
        {
            bool firstCall  = false;
            bool secondCall = false;
            bool thirdCall  = false;

            OneThirstyDude dude = new OneThirstyDude();
            Soda           bru  = new Soda();

            bru.Pop += (sender, soda) => firstCall = true;
            bru.Pop += (sender, soda) => { secondCall = true; throw new Exception(); };
            bru.Pop += (sender, soda) => { thirdCall = true; };

            DefensiveEventRaiser eventRaiser = new DefensiveEventRaiser();

            IEventExceptionsCollector exceptions = bru.OnPop("Iron Brew", eventRaiser);

            Assert.AreEqual(1, exceptions.Exceptions.Count);
            Assert.IsTrue(firstCall);
            Assert.IsTrue(secondCall);
            Assert.IsTrue(thirdCall);
        }