当前位置: 首页>>代码示例>>C#>>正文


C# MainViewModel.OnStudioClosing方法代码示例

本文整理汇总了C#中MainViewModel.OnStudioClosing方法的典型用法代码示例。如果您正苦于以下问题:C# MainViewModel.OnStudioClosing方法的具体用法?C# MainViewModel.OnStudioClosing怎么用?C# MainViewModel.OnStudioClosing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainViewModel的用法示例。


在下文中一共展示了MainViewModel.OnStudioClosing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainViewModel_OnStudioClosing_CallsSchedulerOnClosingClosesSuccessfully

        public void MainViewModel_OnStudioClosing_CallsSchedulerOnClosingClosesSuccessfully()
        {
            //Barney, commented out when I removed the feedback stuff from the studio
            //SetupDefaultMef();
            var eventPublisher = new Mock<IEventAggregator>();
            var environmentRepository = new Mock<IEnvironmentRepository>();
            environmentRepository.Setup(repo => repo.Source).Returns(new Mock<IEnvironmentModel>().Object);
            var versionChecker = new Mock<IVersionChecker>();
            var asyncWorker = new Mock<IAsyncWorker>();
            asyncWorker.Setup(w => w.Start(It.IsAny<System.Action>(), It.IsAny<System.Action>())).Verifiable();
            var connected1 = new Mock<IEnvironmentModel>();
            var connected2 = new Mock<IEnvironmentModel>();
            var notConnected = new Mock<IEnvironmentModel>();
            connected1.Setup(a => a.IsConnected).Returns(true).Verifiable();
            connected1.Setup(a => a.Disconnect()).Verifiable();
            connected2.Setup(a => a.IsConnected).Returns(true).Verifiable();
            connected2.Setup(a => a.Disconnect()).Verifiable();
            IList<IEnvironmentModel> lst = new List<IEnvironmentModel> { connected1.Object, connected2.Object, notConnected.Object };
            environmentRepository.Setup(repo => repo.All()).Returns(lst);
            var mvm = new MainViewModel(eventPublisher.Object, asyncWorker.Object, environmentRepository.Object, versionChecker.Object, false);
            var popup = new Mock<IPopupController>();
            popup.Setup(a => a.ShowSchedulerCloseConfirmation()).Returns(MessageBoxResult.Yes).Verifiable();
            var scheduler = new SchedulerViewModelForTesting(EventPublishers.Aggregator, new DirectoryObjectPickerDialog(), popup.Object, new TestAsyncWorker()) { RetValue = true, WorkSurfaceContext = WorkSurfaceContext.Scheduler };
            var task = new Mock<IScheduledResource>();
            task.Setup(a => a.IsDirty).Returns(true);
            scheduler.SelectedTask = task.Object;
            var vm = new WorkSurfaceContextViewModel(new EventAggregator(), new WorkSurfaceKey(), scheduler, new Mock<IPopupController>().Object, (a, b) => { });
            environmentRepository.Setup(repo => repo.All()).Returns(new List<IEnvironmentModel>());
            mvm.Items.Add(vm);
            Assert.IsTrue(mvm.OnStudioClosing());

        }
开发者ID:ndubul,项目名称:Chillas,代码行数:32,代码来源:MainViewModelTest.cs

示例2: MainViewModel_OnStudioClosing_CallsSettingsOnClosingDirty

        public void MainViewModel_OnStudioClosing_CallsSettingsOnClosingDirty()
        {
            //Barney, commented out when I removed the feedback stuff from the studio
            //SetupDefaultMef();
            var eventPublisher = new Mock<IEventAggregator>();
            var environmentRepository = new Mock<IEnvironmentRepository>();
            environmentRepository.Setup(repo => repo.Source).Returns(new Mock<IEnvironmentModel>().Object);
            var versionChecker = new Mock<IVersionChecker>();
            var asyncWorker = new Mock<IAsyncWorker>();
            asyncWorker.Setup(w => w.Start(It.IsAny<System.Action>(), It.IsAny<System.Action>())).Verifiable();
            var connected1 = new Mock<IEnvironmentModel>();
            var connected2 = new Mock<IEnvironmentModel>();
            var notConnected = new Mock<IEnvironmentModel>();
            connected1.Setup(a => a.IsConnected).Returns(true).Verifiable();
            connected1.Setup(a => a.Disconnect()).Verifiable();
            connected2.Setup(a => a.IsConnected).Returns(true).Verifiable();
            connected2.Setup(a => a.Disconnect()).Verifiable();
            IList<IEnvironmentModel> lst = new List<IEnvironmentModel> { connected1.Object, connected2.Object, notConnected.Object };
            environmentRepository.Setup(repo => repo.All()).Returns(lst);
            var mvm = new MainViewModel(eventPublisher.Object, asyncWorker.Object, environmentRepository.Object, versionChecker.Object, false);
            var popup = new Mock<IPopupController>();

            var settings = new SettingsViewModelForTest(EventPublishers.Aggregator, popup.Object, AsyncWorkerTests.CreateSynchronousAsyncWorker().Object, new NativeWindow()) { RetValue = true, WorkSurfaceContext = WorkSurfaceContext.Settings };
            var task = new Mock<IScheduledResource>();
            task.Setup(a => a.IsDirty).Returns(true);
            settings.IsDirty = true;
            var vm = new WorkSurfaceContextViewModel(new EventAggregator(), new WorkSurfaceKey(), settings, new Mock<IPopupController>().Object, (a, b) => { });
            environmentRepository.Setup(repo => repo.All()).Returns(new List<IEnvironmentModel>());
            mvm.Items.Add(vm);
            Assert.IsTrue(mvm.OnStudioClosing());

        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:32,代码来源:MainViewModelTest.cs


注:本文中的MainViewModel.OnStudioClosing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。