本文整理汇总了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());
}
示例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());
}