public void AddMissingDataListItemsWithUnusedDataListItemsExpectedItemsToBeSetToNotUsed() { var eventAggregator = new Mock<IEventAggregator>().Object; Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock(); mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(GetAddMissingWorkflowXml()); var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator); var dataListItems = new OptomizedObservableCollection<IDataListItemModel>(); IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty); IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty); dataListItems.Add(dataListItem); dataListItems.Add(secondDataListItem); DataListSingleton.SetDataList(dataListViewModel); Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes); dataListViewModel.ScalarCollection.Clear(); dataListViewModel.RecsetCollection.Clear(); dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add); WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModel(eventAggregator, mockResourceModel.Object, null, false); workflowDesigner.PopUp = mockPopUp.Object; workflowDesigner.AddMissingWithNoPopUpAndFindUnusedDataListItems(); Assert.AreEqual(2, dataListViewModel.ScalarCollection.Count); Assert.AreEqual(0, dataListViewModel.RecsetCollection.Count); workflowDesigner.Dispose(); }
public void FindUnusedDataListItemsWithUnusedDataListItemsExpectedItemsToBeSetToNotUsed() { var eventAggregator = new EventAggregator(); Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock(); mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest()); var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator); var dataListItems = new OptomizedObservableCollection<IDataListItemModel>(); IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty); IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty); dataListItems.Add(dataListItem); dataListItems.Add(secondDataListItem); DataListSingleton.SetDataList(dataListViewModel); Mock<IPopupController> mockPopUp = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes); dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add); dataListViewModel.RecsetCollection.Clear(); WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModelWithDesignerAttributesInitialized(mockResourceModel.Object, eventAggregator); workflowDesigner.PopUp = mockPopUp.Object; // workflowDesigner.MediatorRepo = _mockMediatorRepo.Object; Assert.IsTrue(dataListViewModel.ScalarCollection[0].IsUsed); Assert.IsTrue(dataListViewModel.ScalarCollection[1].IsUsed); workflowDesigner.AddMissingWithNoPopUpAndFindUnusedDataListItems(); workflowDesigner.Dispose(); Assert.IsTrue(!dataListViewModel.ScalarCollection[0].IsUsed); }
public void RemoveAllUnusedDataListObjectsWithItemsNotUsedExpectedItemsRemoved() { var eventAggregator = new EventAggregator(); Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock(); mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest()); var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator); var dataListItems = new OptomizedObservableCollection<IDataListItemModel>(); IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty); IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty); dataListItems.Add(dataListItem); dataListItems.Add(secondDataListItem); DataListSingleton.SetDataList(dataListViewModel); dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add); dataListViewModel.RecsetCollection.Clear(); WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModel(eventAggregator, mockResourceModel.Object, null, false); workflowDesigner.DispatcherUpdateAction = (a => DataListSingleton.ActiveDataList.UpdateDataListItems(workflowDesigner.ResourceModel, a)); workflowDesigner.AddMissingWithNoPopUpAndFindUnusedDataListItems(); dataListViewModel.RemoveUnusedDataListItems(); workflowDesigner.Dispose(); Assert.AreEqual(0, dataListViewModel.ScalarCollection.Count); }
public void SetModelToDirtyAndExpectThatItemsWillBeAdded() { var eventAggregator = new EventAggregator(); Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock(); mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(WorkflowXAMLForTest()); var dataListViewModel = CreateDataListViewModel(mockResourceModel, eventAggregator); var dataListItems = new OptomizedObservableCollection<IDataListItemModel>(); IDataListItemModel dataListItem = new DataListItemModel("scalar1", enDev2ColumnArgumentDirection.Input, string.Empty); IDataListItemModel secondDataListItem = new DataListItemModel("scalar2", enDev2ColumnArgumentDirection.Input, string.Empty); dataListItems.Add(dataListItem); dataListItems.Add(secondDataListItem); DataListSingleton.SetDataList(dataListViewModel); dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add); dataListViewModel.RecsetCollection.Clear(); WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModel(eventAggregator, mockResourceModel.Object, null, false); workflowDesigner.DispatcherUpdateAction = (a => DataListSingleton.ActiveDataList.UpdateDataListItems(workflowDesigner.ResourceModel, a)); IDataListItemModel dataListItem3 = new DataListItemModel("scalar8", enDev2ColumnArgumentDirection.Input, string.Empty); workflowDesigner.ChangeIsPossible = true; dataListItems.Add(dataListItem3); Thread.Sleep(3000); workflowDesigner.Dispose(); Assert.AreEqual(5, dataListViewModel.ScalarCollection.Count); }
public void MissingPartsMessageOnlySentWhenThereWorkToDoExpect1Call() { // Set up event agg var evtAg = new Mock<IEventAggregator>(); Mock<IContextualResourceModel> mockResourceModel = Dev2MockFactory.SetupResourceModelMock(); mockResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(GetAddMissingWorkflowXml()); var mockDataListViewModel = new Mock<IDataListViewModel>(); mockDataListViewModel.Setup(model => model.ScalarCollection).Returns(new OptomizedObservableCollection<IDataListItemModel>()); mockDataListViewModel.Setup(model => model.UpdateDataListItems(It.IsAny<IResourceModel>(), It.IsAny<IList<IDataListVerifyPart>>())).Verifiable(); var dataListViewModel = mockDataListViewModel.Object; var dataListItems = new OptomizedObservableCollection<IDataListItemModel>(); DataListSingleton.SetDataList(dataListViewModel); dataListItems.ToList().ForEach(dataListViewModel.ScalarCollection.Add); WorkflowDesignerViewModel workflowDesigner = CreateWorkflowDesignerViewModelWithDesignerAttributesInitialized(mockResourceModel.Object, evtAg.Object); workflowDesigner.AddMissingWithNoPopUpAndFindUnusedDataListItems(); workflowDesigner.Dispose(); mockDataListViewModel.Verify(model => model.UpdateDataListItems(It.IsAny<IResourceModel>(), It.IsAny<IList<IDataListVerifyPart>>()), Times.Once()); }