Exemplo n.º 1
0
        public void AddWeakHandler_WhenCrossSubscriptions_NotAlives()
        {
            var handlers = new List <WeakEventHandler <EventArgs> >();

            WeakHelpers.ExecuteAndCollect(() =>
            {
                var pubsub1 = new Subscriber();
                var pubsub2 = new Subscriber();
                handlers.Add(pubsub2.AddWeakHandler <EventArgs>(nameof(Publisher.Event), pubsub1.OnEventRaised));
                handlers.Add(pubsub1.AddWeakHandler <EventArgs>(nameof(Publisher.Event), pubsub2.OnEventRaised));
            });

            Assert.IsTrue(handlers.Any((a) => !a.IsAlive));
        }