public void ViewModelIsGarbageCollectedWhenSetToNull()
        {
            var viewModel = new ViewModel();
            var lifetimeMonitor = new WeakReference(viewModel);

            viewModel = null;

            Helper.RunGarbageCollection();

            Assert.IsFalse(lifetimeMonitor.IsAlive);
        }
        public void ViewModelIsGarbageCollectedWhileStillSubscribedToTheMessageBus()
        {
            var messageBus = new MessageBus();
            var subscribingViewModel = new ViewModel();
            var lifetimeMonitor = new WeakReference(subscribingViewModel);

            subscribingViewModel.SubscribeToMessageBus(messageBus);

            subscribingViewModel = null;

            Helper.RunGarbageCollection();

            Assert.IsFalse(lifetimeMonitor.IsAlive);
        }