예제 #1
0
        public void MembershipModel_Dispose_Ok()
        {
            // creates a Task ViewModel
            ViewModel.ProjectMembershipViewModel viewModel = new ViewModel.ProjectMembershipViewModel(
                null,
                null,
                null,
                new ProjectMembership(),
                new MemberProfile());

            // creates the view
            FakeView view = new FakeView();
            view.Model = viewModel;

            //if (System.Windows.Application.Current == null) {
            //    ScrumFactory.Windows.App application = new ScrumFactory.Windows.App();
            //    application.InitializeComponent();
            //}

            //ProjectTeam view = new ProjectTeam();
            //view.Model = viewModel;

            // clears VM reference
            WeakReference msVMRef = new WeakReference(viewModel);
            viewModel.Dispose();
            viewModel = null;
            view.Model = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Assert.IsNull(msVMRef.Target, "ViewModel was not garbage collected. Check OnDispose method to see if all Commands and Events were unsubscribed");
        }
예제 #2
0
        public void RiskViewModel_Dispose_Ok()
        {
            // creates a Task ViewModel
            IEventAggregator aggregator = new ScrumFactory.Composition.EventAggregator();
            ViewModel.RiskViewModel viewModel = new ViewModel.RiskViewModel(null, null, new Risk());

            // creates the view
            FakeView view = new FakeView();
            view.Model = viewModel;

            // clears VM reference
            WeakReference riskVMRef = new WeakReference(viewModel);
            viewModel.Dispose();
            viewModel = null;
            view.Model = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Assert.IsNull(riskVMRef.Target, "ViewModel was not garbage collected. Check OnDispose method to see if all Commands and Events were unsubscribed");
        }