本文整理汇总了C#中WorkSurfaceContextViewModel类的典型用法代码示例。如果您正苦于以下问题:C# WorkSurfaceContextViewModel类的具体用法?C# WorkSurfaceContextViewModel怎么用?C# WorkSurfaceContextViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkSurfaceContextViewModel类属于命名空间,在下文中一共展示了WorkSurfaceContextViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupPane
static ContentPaneFactory SetupPane(out WorkSurfaceContextViewModel workSurfaceContextViewModel, out ContentPane userControl, MessageBoxResult messageBoxResult)
{
var pane = new ContentPaneFactory();
var eventAggregator = new Mock<IEventAggregator>();
var workSurfaceViewModel = new Mock<ITestWorkSurfaceViewModel>();
workSurfaceViewModel.SetupGet(w => w.WorkSurfaceContext).Returns(WorkSurfaceContext.Workflow);
workSurfaceViewModel.SetupGet(w => w.ResourceModel).Returns(new TestResourceModel { Authorized = true });
var localhost = new Mock<IEnvironmentModel>();
localhost.Setup(e => e.ID).Returns(Guid.Empty);
localhost.Setup(e => e.IsConnected).Returns(true);
var environmentRepository = new Mock<IEnvironmentRepository>();
environmentRepository.Setup(c => c.All()).Returns(new[] { localhost.Object });
environmentRepository.Setup(c => c.Source).Returns(localhost.Object);
var eventPublisher = new Mock<IEventAggregator>();
var asyncWorker = AsyncWorkerTests.CreateSynchronousAsyncWorker();
var versionChecker = new Mock<IVersionChecker>();
var browserPopupController = new Mock<IBrowserPopupController>();
var savePopup = new Mock<IPopupController>();
savePopup.Setup(s => s.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButton>(), It.IsAny<MessageBoxImage>(), It.IsAny<string>())).Returns(messageBoxResult);
var mainViewModel = new MainViewModelMock(eventPublisher.Object, asyncWorker.Object, environmentRepository.Object, versionChecker.Object,new Mock<IStudioResourceRepository>().Object, new Mock<IConnectControlSingleton>().Object, new Mock<IConnectControlViewModel>().Object, false, browserPopupController.Object) { IsBusyDownloadingInstaller = () => false, PopupProvider = savePopup.Object };
workSurfaceContextViewModel = new WorkSurfaceContextViewModel(eventAggregator.Object, new WorkSurfaceKey
{
EnvironmentID = Guid.NewGuid(),
ResourceID = Guid.NewGuid(),
ServerID = Guid.NewGuid(),
WorkSurfaceContext = WorkSurfaceContext.Workflow
}, workSurfaceViewModel.Object, new Mock<IPopupController>().Object, (a, b) => { })
{
Parent = mainViewModel
};
pane.ItemsSource = new List<WorkSurfaceContextViewModel>
{
workSurfaceContextViewModel
};
userControl = new ContentPane { DataContext = workSurfaceContextViewModel };
return pane;
}
示例2: WorkSurfaceContextViewModel_SaveCallsCheckForServerMessages
public void WorkSurfaceContextViewModel_SaveCallsCheckForServerMessages()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
mockEnvironmentModel.SetupGet(p => p.IsConnected).Returns(true);
var mockRepository = new Mock<IResourceRepository>();
mockRepository.Setup(c => c.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(new ExecuteMessage());
mockRepository.Setup(m => m.Save(It.IsAny<IResourceModel>())).Verifiable();
mockRepository.Setup(c => c.SaveToServer(It.IsAny<IResourceModel>())).Returns(new ExecuteMessage());
mockEnvironmentModel.SetupGet(p => p.ResourceRepository).Returns(mockRepository.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(m => m.BindToModel()).Verifiable();
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>();
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, workSurfaceViewModel.Object);
var mockResourceModel = new Mock<IContextualResourceModel>();
mockResourceModel.SetupGet(p => p.Environment).Returns(environmentModel);
mockResourceModel.Setup(m => m.UserPermissions).Returns(Permissions.Contribute);
//------------Execute Test---------------------------
workSurfaceContextViewModel.Handle(new SaveResourceMessage(mockResourceModel.Object, false, false));
}
示例3: WorkSurfaceContextViewModel_Handle_Save_WhenContextualResourceModelIsNotNull
public void WorkSurfaceContextViewModel_Handle_Save_WhenContextualResourceModelIsNotNull()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
mockEnvironmentModel.SetupGet(p => p.IsConnected).Returns(true);
var mockRepository = new Mock<IResourceRepository>();
mockRepository.Setup(c => c.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(new ExecuteMessage());
mockRepository.Setup(m => m.Save(It.IsAny<IResourceModel>())).Verifiable();
mockRepository.Setup(c => c.SaveToServer(It.IsAny<IResourceModel>())).Returns(new ExecuteMessage());
mockEnvironmentModel.SetupGet(p => p.ResourceRepository).Returns(mockRepository.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(m => m.BindToModel()).Verifiable();
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>();
var popup = new Mock<IPopupController>();
bool called = false;
var mockResourceModel = new Mock<IContextualResourceModel>();
mockResourceModel.SetupGet(p => p.Environment).Returns(environmentModel);
mockResourceModel.Setup(m => m.UserPermissions).Returns(Permissions.Contribute);
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(new Mock<IEventAggregator>().Object, workSurfaceKey, workSurfaceViewModel.Object, popup.Object, (a, b) => { called = true; });
mockWorkSurfaceViewModel.Setup(a => a.ResourceModel).Returns(mockResourceModel.Object);
workSurfaceContextViewModel.WorkSurfaceViewModel = new WorkSurfaceViewModelTest();
var dlvm = new Mock<IDataListViewModel>();
dlvm.Setup(a => a.HasErrors).Returns(false);
workSurfaceContextViewModel.DataListViewModel = dlvm.Object;
mockResourceModel.Setup(a => a.IsNewWorkflow).Returns(true);
//------------Execute Test---------------------------
workSurfaceContextViewModel.Handle(new SaveResourceMessage(mockResourceModel.Object, false, false));
//------------Assert---------------------------------
Assert.IsTrue(called);
}
示例4: WorkSurfaceContextViewModel_Handle_Save_InvalidXml_CausesPopup
public void WorkSurfaceContextViewModel_Handle_Save_InvalidXml_CausesPopup()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
mockEnvironmentModel.SetupGet(p => p.IsConnected).Returns(true);
var mockRepository = new Mock<IResourceRepository>();
mockRepository.Setup(c => c.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(new ExecuteMessage());
mockRepository.Setup(m => m.Save(It.IsAny<IResourceModel>())).Verifiable();
mockRepository.Setup(c => c.SaveToServer(It.IsAny<IResourceModel>())).Returns(new ExecuteMessage());
mockEnvironmentModel.SetupGet(p => p.ResourceRepository).Returns(mockRepository.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(m => m.BindToModel()).Verifiable();
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>();
var popup = new Mock<IPopupController>();
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(new Mock<IEventAggregator>().Object, workSurfaceKey, workSurfaceViewModel.Object, popup.Object, (a, b) => { });
var mockResourceModel = new Mock<IContextualResourceModel>();
mockResourceModel.SetupGet(p => p.Environment).Returns(environmentModel);
mockResourceModel.Setup(m => m.UserPermissions).Returns(Permissions.Contribute);
var dlvm = new Mock<IDataListViewModel>();
dlvm.Setup(a => a.HasErrors).Returns(true);
workSurfaceContextViewModel.DataListViewModel = dlvm.Object;
//------------Execute Test---------------------------
workSurfaceContextViewModel.Handle(new SaveResourceMessage(mockResourceModel.Object, false, false));
//------------Assert---------------------------------
popup.Verify(a => a.Show(It.IsAny<string>(), "Error Saving", MessageBoxButton.OK, MessageBoxImage.Error, "true"));
}
示例5: WorkSurfaceContextViewModel_DebugOutputMessage_DebugStateHasData_OnlyOneRootItemIsDisplayed
public void WorkSurfaceContextViewModel_DebugOutputMessage_DebugStateHasData_OnlyOneRootItemIsDisplayed()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey { WorkSurfaceContext = WorkSurfaceContext.Scheduler };
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>().Object;
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, workSurfaceViewModel) { DebugOutputViewModel = { DebugStatus = DebugStatus.Executing } };
const string msg = "[{\"$type\":\"Dev2.Diagnostics.Debug.DebugState, Dev2.Diagnostics\",\"ID\":\"cd902be2-a202-4d54-8c07-c5f56bae97fe\",\"ParentID\":\"00000000-0000-0000-0000-000000000000\",\"ServerID\":\"00000000-0000-0000-0000-000000000000\",\"EnvironmentID\":\"00000000-0000-0000-0000-000000000000\",\"ClientID\":\"00000000-0000-0000-0000-000000000000\",\"StateType\":64,\"DisplayName\":\"dave\",\"HasError\":true,\"ErrorMessage\":\"Service [ dave ] not found.\",\"Version\":\"\",\"Name\":\"DynamicServicesInvoker\",\"ActivityType\":0,\"Duration\":\"00:00:00\",\"DurationString\":\"PT0S\",\"StartTime\":\"2014-03-20T17:23:14.0224329+02:00\",\"EndTime\":\"2014-03-20T17:23:14.0224329+02:00\",\"Inputs\":[],\"Outputs\":[],\"Server\":\"\",\"WorkspaceID\":\"00000000-0000-0000-0000-000000000000\",\"OriginalInstanceID\":\"00000000-0000-0000-0000-000000000000\",\"OriginatingResourceID\":\"00000000-0000-0000-0000-000000000000\",\"IsSimulation\":false,\"Message\":null,\"NumberOfSteps\":0,\"Origin\":\"\",\"ExecutionOrigin\":0,\"ExecutionOriginDescription\":null,\"ExecutingUser\":null,\"SessionID\":\"00000000-0000-0000-0000-000000000000\"}]";
var serializer = new Dev2JsonSerializer();
var tmp = serializer.Deserialize<List<IDebugState>>(msg);
//------------Execute Test---------------------------
workSurfaceContextViewModel.Handle(new DebugOutputMessage(tmp));
//------------Assert Results-------------------------
Assert.AreEqual(1, workSurfaceContextViewModel.DebugOutputViewModel.RootItems.Count);
}
示例6: MainViewModelDeactivateItemWithPreviousItemOpenExpectedActiveItemToBePreviousItem
public void MainViewModelDeactivateItemWithPreviousItemOpenExpectedActiveItemToBePreviousItem()
{
lock (syncroot)
{
var wsiRepo = new Mock<IWorkspaceItemRepository>();
wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
wsiRepo.Setup(r => r.Write()).Verifiable();
#region Setup ImportService - GRRR!
var importServiceContext = new ImportServiceContext();
ImportService.CurrentContext = importServiceContext;
ImportService.Initialize(new List<ComposablePartCatalog>
{
new FullTestAggregateCatalog()
});
ImportService.AddExportedValueToContainer(wsiRepo.Object);
ImportService.AddExportedValueToContainer(new Mock<IEventAggregator>().Object);
#endregion
var envRepo = new Mock<IEnvironmentRepository>();
var mockMainViewModel = new MainViewModelPersistenceMock(envRepo.Object, false);
mockMainViewModel.EventAggregator = ImportService.GetExportValue<IEventAggregator>();
var resourceID = Guid.NewGuid();
var serverID = Guid.NewGuid();
#region Setup WorkSurfaceContextViewModel1
var resourceRepo = new Mock<IResourceRepository>();
resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();
var envConn = new Mock<IEnvironmentConnection>();
var env = new Mock<IEnvironmentModel>();
env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
env.Setup(e => e.Connection).Returns(envConn.Object);
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(m => m.Environment).Returns(env.Object);
resourceModel.Setup(m => m.ID).Returns(resourceID);
var workflowHelper = new Mock<IWorkflowHelper>();
var designerViewModel = new WorkflowDesignerViewModel(resourceModel.Object, workflowHelper.Object, false);
var contextViewModel1 = new WorkSurfaceContextViewModel(
new WorkSurfaceKey { ResourceID = resourceID, ServerID = serverID, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
designerViewModel);
#endregion
mockMainViewModel.Items.Add(contextViewModel1);
serverID = Guid.NewGuid();
resourceID = Guid.NewGuid();
mockMainViewModel.PopupProvider = Dev2MockFactory.CreateIPopup(MessageBoxResult.No).Object;
mockMainViewModel.ActivateItem(mockMainViewModel.Items[0]);
mockMainViewModel.ActivateItem(mockMainViewModel.Items[1]);
mockMainViewModel.CallDeactivate(mockMainViewModel.Items[1]);
Assert.AreEqual(mockMainViewModel.Items[0], mockMainViewModel.ActiveItem);
}
}
示例7: SetupImportServiceForPersistenceTests
public void MainViewModelOnDeactivateWithTrueExpectedSavesResourceModels_WhenEnvironmentNotConnectedDoesNotCallSave()
{
var wsiRepo = new Mock<IWorkspaceItemRepository>();
wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
wsiRepo.Setup(r => r.UpdateWorkspaceItem(It.IsAny<IContextualResourceModel>(), It.Is<bool>(b => b))).Verifiable();
SetupImportServiceForPersistenceTests(wsiRepo);
var resourceID = Guid.NewGuid();
var serverID = Guid.NewGuid();
#region Setup resourceModel
var resourceRepo = new Mock<IResourceRepository>();
resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();
var envConn = new Mock<IEnvironmentConnection>();
var env = new Mock<IEnvironmentModel>();
envConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
env.Setup(e => e.Connection).Returns(envConn.Object);
env.Setup(e => e.IsConnected).Returns(false);
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(m => m.Environment).Returns(env.Object);
resourceModel.Setup(m => m.ID).Returns(resourceID);
resourceModel.Setup(m => m.ResourceName).Returns("Some resource name 5");
#endregion
Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.No);
var workflowHelper = new Mock<IWorkflowHelper>();
var designerViewModel = new WorkflowDesignerViewModel(new Mock<IEventAggregator>().Object, resourceModel.Object, workflowHelper.Object, mockPopUp.Object, new TestAsyncWorker(), false);
var contextViewModel = new WorkSurfaceContextViewModel(
new WorkSurfaceKey { ResourceID = resourceID, ServerID = serverID, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
designerViewModel);
var envRepo = new Mock<IEnvironmentRepository>();
envRepo.Setup(r => r.All()).Returns(new[] { env.Object });
envRepo.Setup(e => e.Source).Returns(env.Object);
envRepo.Setup(r => r.ReadSession()).Returns(new[] { env.Object.ID });
var viewModel = new MainViewModelPersistenceMock(envRepo.Object, false);
viewModel.Items.Add(contextViewModel);
viewModel.TestClose();
wsiRepo.Verify(r => r.UpdateWorkspaceItem(It.IsAny<IContextualResourceModel>(), It.Is<bool>(b => b)), Times.Never());
resourceRepo.Verify(r => r.Save(It.IsAny<IResourceModel>()), Times.Never());
}
示例8: MainViewModel_UnsavedWorkflowDialog_WhenXPressed_WorkflowRemainsOpen
public void MainViewModel_UnsavedWorkflowDialog_WhenXPressed_WorkflowRemainsOpen()
{
var wsiRepo = new Mock<IWorkspaceItemRepository>();
wsiRepo.Setup(r => r.WorkspaceItems).Returns(() => new List<IWorkspaceItem>());
wsiRepo.Setup(r => r.Write()).Verifiable();
#region Setup ImportService - GRRR!
SetupImportServiceForPersistenceTests(wsiRepo);
#endregion
var envRepo = new Mock<IEnvironmentRepository>();
var resourceRepo = new Mock<IResourceRepository>();
resourceRepo.Setup(r => r.Save(It.IsAny<IResourceModel>())).Verifiable();
var envConn = new Mock<IEnvironmentConnection>();
var env = new Mock<IEnvironmentModel>();
envConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
env.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object);
env.Setup(e => e.Connection).Returns(envConn.Object);
envRepo.Setup(r => r.All()).Returns(new[] { env.Object });
envRepo.Setup(e => e.Source).Returns(env.Object);
envRepo.Setup(r => r.ReadSession()).Returns(new[] { env.Object.ID });
Mock<IAsyncWorker> asyncWorker = AsyncWorkerTests.CreateSynchronousAsyncWorker();
var mockMainViewModel = new MainViewModelPersistenceMock(envRepo.Object, asyncWorker.Object, false);
var resourceID = Guid.NewGuid();
var serverID = Guid.NewGuid();
#region Setup WorkSurfaceContextViewModel1
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(m => m.Environment).Returns(env.Object);
resourceModel.Setup(m => m.ID).Returns(resourceID);
resourceModel.Setup(r => r.IsAuthorized(AuthorizationContext.Contribute)).Returns(true);
resourceModel.Setup(m => m.ResourceName).Returns("Some resource name 3");
Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.No);
mockPopUp.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButton>(), It.IsAny<MessageBoxImage>(), It.IsAny<string>())).Verifiable();
var workflowHelper = new Mock<IWorkflowHelper>();
var designerViewModel = new WorkflowDesignerViewModel(new Mock<IEventAggregator>().Object, resourceModel.Object, workflowHelper.Object, mockPopUp.Object, new TestAsyncWorker(), false);
var contextViewModel1 = new WorkSurfaceContextViewModel(
new WorkSurfaceKey { ResourceID = resourceID, ServerID = serverID, WorkSurfaceContext = designerViewModel.WorkSurfaceContext },
designerViewModel);
#endregion
mockMainViewModel.Items.Add(contextViewModel1);
mockMainViewModel.PopupProvider = mockPopUp.Object;
mockMainViewModel.ActivateItem(mockMainViewModel.Items[0]);
mockMainViewModel.ActivateItem(mockMainViewModel.Items[1]);
mockMainViewModel.CallDeactivate(mockMainViewModel.Items[1]);
Assert.AreEqual(mockMainViewModel.Items[1], mockMainViewModel.ActiveItem);
mockPopUp.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButton>(), It.IsAny<MessageBoxImage>(), It.IsAny<string>()), Times.Once());
}
示例9: WorkSurfaceContextViewModel_Constructor_SchedularWorksurfaceContext_DebugOutputViewModelNotNull
public void WorkSurfaceContextViewModel_Constructor_SchedularWorksurfaceContext_DebugOutputViewModelNotNull()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey { WorkSurfaceContext = WorkSurfaceContext.Scheduler };
var mockWorkSurfaceViewModel = new SchedulerViewModel();
//------------Execute Test---------------------------
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, mockWorkSurfaceViewModel);
//------------Assert Results-------------------------
Assert.IsNotNull(workSurfaceContextViewModel);
Assert.IsNotNull(workSurfaceContextViewModel.DebugOutputViewModel);
}
示例10: WorkSurfaceContextViewModel_CanViewInBrowser_ExpectTrue
public void WorkSurfaceContextViewModel_CanViewInBrowser_ExpectTrue()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(m => m.BindToModel()).Verifiable();
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>();
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, workSurfaceViewModel.Object) { WorkSurfaceViewModel = new WorkSurfaceViewModelTest() };
//------------Execute Test---------------------------
Assert.IsTrue(workSurfaceContextViewModel.CanViewInBrowser());
}
示例11: WorkSurfaceContextViewModel_CanSave_ExpectTrue
public void WorkSurfaceContextViewModel_CanSave_ExpectTrue()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(m => m.BindToModel()).Verifiable();
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>();
// ReSharper disable UseObjectOrCollectionInitializer
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, workSurfaceViewModel.Object);
// ReSharper restore UseObjectOrCollectionInitializer
workSurfaceContextViewModel.WorkSurfaceViewModel = new WorkSurfaceViewModelTest();
//------------Execute Test---------------------------
Assert.IsTrue(workSurfaceContextViewModel.CanSave());
}
示例12: WorkSurfaceContextViewModel_BindToModel_CallsBindToModelOnWorkSurfaceViewModel
public void WorkSurfaceContextViewModel_BindToModel_CallsBindToModelOnWorkSurfaceViewModel()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(m => m.BindToModel()).Verifiable();
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>();
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, workSurfaceViewModel.Object);
//------------Execute Test---------------------------
workSurfaceContextViewModel.BindToModel();
//------------Assert---------------------------------
mockWorkSurfaceViewModel.Verify(m => m.BindToModel(), Times.Once());
}
示例13: CreateWorkSurfaceContextViewModel
static WorkSurfaceContextViewModel CreateWorkSurfaceContextViewModel(Permissions userPermissions)
{
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var authService = new Mock<IAuthorizationService>();
authService.Setup(s => s.IsAuthorized(It.IsAny<AuthorizationContext>(), It.IsAny<string>())).Returns(true);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true);
mockEnvironmentModel.Setup(model => model.AuthorizationService).Returns(authService.Object);
var environmentModel = mockEnvironmentModel.Object;
var resourceModel = new ResourceModel(environmentModel)
{
ID = Guid.NewGuid(),
ResourceName = "TestResource" + Guid.NewGuid(),
UserPermissions = userPermissions
};
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(model => model.ResourceModel).Returns(resourceModel);
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>().Object;
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(new WorkSurfaceKey(), workSurfaceViewModel)
{
DebugOutputViewModel = { DebugStatus = DebugStatus.Ready }
};
workSurfaceContextViewModel.DebugCommand.UpdateContext(environmentModel, resourceModel);
workSurfaceContextViewModel.QuickDebugCommand.UpdateContext(environmentModel, resourceModel);
return workSurfaceContextViewModel;
}
示例14: WorkSurfaceContextViewModel_SaveCallsCheckForServerMessages_NoMessagesAvailable_NothingHappen
public void WorkSurfaceContextViewModel_SaveCallsCheckForServerMessages_NoMessagesAvailable_NothingHappen()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
mockEnvironmentModel.SetupGet(p => p.IsConnected).Returns(true);
var mockRepository = new Mock<IResourceRepository>();
mockRepository.Setup(c => c.FetchResourceDefinition(It.IsAny<IEnvironmentModel>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<bool>())).Returns(new ExecuteMessage());
mockRepository.Setup(m => m.Save(It.IsAny<IResourceModel>())).Verifiable();
mockRepository.Setup(c => c.SaveToServer(It.IsAny<IResourceModel>())).Returns(new ExecuteMessage());
mockEnvironmentModel.SetupGet(p => p.ResourceRepository).Returns(mockRepository.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
mockWorkSurfaceViewModel.Setup(m => m.BindToModel()).Verifiable();
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>();
// object to work on
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, workSurfaceViewModel.Object);
var st = new Mock<IStudioCompileMessageRepoFactory>();
var mr = new Mock<IStudioCompileMessageRepo>();
workSurfaceContextViewModel.StudioCompileMessageRepoFactory = st.Object;
st.Setup(x => x.Create()).Returns(mr.Object);
mr.Setup(a => a.GetCompileMessagesFromServer(It.IsAny<IContextualResourceModel>())).Returns(new CompileMessageList());
var resourceChangedFactory = new Mock<IResourceChangeHandlerFactory>();
var rsHandler = new Mock<IResourceChangeHandler>();
resourceChangedFactory.Setup(a => a.Create(new Mock<IEventAggregator>().Object)).Returns(rsHandler.Object);
workSurfaceContextViewModel.ResourceChangeHandlerFactory = resourceChangedFactory.Object;
var mockResourceModel = new Mock<IContextualResourceModel>();
mockResourceModel.SetupGet(p => p.Environment).Returns(environmentModel);
mockResourceModel.Setup(m => m.UserPermissions).Returns(Permissions.Contribute);
//------------Execute Test---------------------------
workSurfaceContextViewModel.Handle(new SaveResourceMessage(mockResourceModel.Object, false, false));
rsHandler.Verify(a => a.ShowResourceChanged(It.IsAny<IContextualResourceModel>(), It.IsAny<IList<string>>(), null), Times.Never());
}
示例15: WorkSurfaceContextViewModel_Constructor_ValidArguments_DebugOutputViewModelNotNull
public void WorkSurfaceContextViewModel_Constructor_ValidArguments_DebugOutputViewModelNotNull()
{
//------------Setup for test--------------------------
var workSurfaceKey = new WorkSurfaceKey();
var mockWorkSurfaceViewModel = new Mock<IWorkflowDesignerViewModel>();
var mockedConn = new Mock<IEnvironmentConnection>();
mockedConn.Setup(conn => conn.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(model => model.Connection).Returns(mockedConn.Object);
var environmentModel = mockEnvironmentModel.Object;
mockWorkSurfaceViewModel.Setup(model => model.EnvironmentModel).Returns(environmentModel);
var workSurfaceViewModel = mockWorkSurfaceViewModel.As<IWorkSurfaceViewModel>().Object;
//------------Execute Test---------------------------
var workSurfaceContextViewModel = new WorkSurfaceContextViewModel(workSurfaceKey, workSurfaceViewModel);
//------------Assert Results-------------------------
Assert.IsNotNull(workSurfaceContextViewModel);
Assert.IsNotNull(workSurfaceContextViewModel.DebugOutputViewModel);
}