public void DisplayListProcessChangedEventCtorTest()
        {
            var stepEdit = DisplayListRequiredStepEdit.NewStep(1);
            stepEdit.SelectedFields = new DisplayListStepFields();
            var vm = new ProcessFieldDisplayListRequiredStepViewModel(stepEdit, new StepInfo(1), new ProcessFieldViewModel(new FieldEdit(), new ProcessSectionViewModel(Mock.Create<ISectionEdit>())));
            var ppi1 = new PublishedProcessInfo();
            var ppi2 = new PublishedProcessInfo();
            var item = new DisplayListProcessChangedEvent(vm, ppi1, ppi2);

            Assert.AreSame(vm, item.StepViewModel);
            Assert.AreSame(ppi1, item.OldProcess);
            Assert.AreSame(ppi2, item.NewProcess);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisplayListFieldViewModel"/> class.
 /// </summary>
 /// <param name="fieldInfo">The field information.</param>
 /// <param name="parentStep">The parent step.</param>
 public DisplayListFieldViewModel(FieldInfo fieldInfo, ProcessFieldDisplayListRequiredStepViewModel parentStep)
 {
     Model = fieldInfo;
     ParentStepViewModel = parentStep;
     
     if (Model != null && ParentStepViewModel != null)
     {
         _isSelected = ParentStepViewModel.Data.SelectedFields.Contains(FullSystemPath);
     }
 }
コード例 #3
0
 /// <summary>
 /// Creates the field vm.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <param name="parentVM">The parent vm.</param>
 /// <returns>DisplayListFieldViewModel.</returns>
 public DisplayListFieldViewModel CreateFieldVM(FieldInfo field, ProcessFieldDisplayListRequiredStepViewModel parentVM)
 {
     var fieldVM = new DisplayListFieldViewModel(field, parentVM);
     DeploymentService.Container.ComposeParts(fieldVM);
     return fieldVM;
 }
        public void FilterOptionsCommandShouldShowFilterOptionsPopup()
        {
            var filter = Mock.Create<IFilterDescriptor>(Behavior.Loose);
            var stepEdit = DisplayListRequiredStepEdit.NewStep(1);
            stepEdit.SelectedFields = new DisplayListStepFields();

            var processFieldViewModel = new ProcessFieldViewModel(new FieldEdit(), new ProcessSectionViewModel(Mock.Create<ISectionEdit>()));

            var vm = new ProcessFieldDisplayListRequiredStepViewModel(stepEdit, new StepInfo(1), processFieldViewModel);

            var processEdit = Mock.Create<ProcessEdit>(Behavior.Loose);
            var fieldsViewModel = new ProcessFieldsViewModel { Model = processEdit };
            vm.Model = fieldsViewModel;

            var popupFactory = Mock.Create<PopupFactory>(Behavior.Loose);
            var popupBuilder = Mock.Create<PopupBuilder>(Behavior.CallOriginal);
            Mock.Arrange(() => popupFactory.Popup()).Returns(popupBuilder);
            Mock.Arrange(() => popupBuilder.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoNothing();
            vm.ThePopupFactory = popupFactory;

            var filterOptions = Mock.Create<FilterOptionsViewModel>(Behavior.Loose);
            vm.FilterOptionsVM = new Lazy<FilterOptionsViewModel>(() => filterOptions);
            vm.FilterOptionsCommand.Execute(filter);

            Assert.IsTrue(filterOptions.IsUdpEditMode);
            Assert.IsFalse(filterOptions.ShowUdPs);
            Assert.IsFalse(filterOptions.ShowProcessFields);

            Mock.Assert(() => filterOptions.CleanUp(), Occurs.Once());
            Mock.AssertSet(() => filterOptions.FilterDescriptor = filter, Occurs.Once());
        }
        public void RemoveDisplayFieldCommand_ExecuteTest()
        {
            // Arrange.
            var stepInfo = new StepInfo(123);
            var displayField1 = DisplayListFieldEdit.NewDisplayListFieldEdit();
            displayField1.Order = 1;
            var displayField2 = DisplayListFieldEdit.NewDisplayListFieldEdit();
            displayField2.Order = 2;

            var step = DisplayListRequiredStepEdit.NewStep(123);
            step.SelectedFields.Add(displayField1);
            step.SelectedFields.Add(displayField2);

            var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose);
            var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField);

            var selectedFields =
                viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>().ToArray();

            // Act.
            viewModel.RemoveDisplayFieldCommand.Execute(selectedFields[0]);

            // Assert.
            Assert.AreEqual(1, step.SelectedFields.Count);
            Assert.IsFalse(step.SelectedFields.Contains(displayField1));
            Assert.AreEqual(1, viewModel.SelectedDisplayFields.Count);
            Assert.IsFalse(viewModel.SelectedDisplayFields.Contains(selectedFields[0]));
        }
        public void RemoveDisplayFieldCommand_CanExecuteTest()
        {
            // Arrange.
            var stepInfo = new StepInfo(123);
            var displayField1 = DisplayListFieldEdit.NewDisplayListFieldEdit();
            displayField1.Order = 1;
            var displayField2 = DisplayListFieldEdit.NewDisplayListFieldEdit();
            displayField2.Order = 2;

            var step = DisplayListRequiredStepEdit.NewStep(123);
            step.SelectedFields.Add(displayField1);

            var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose);
            var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField);

            var notSelectedField = new ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel();
            notSelectedField.Initialize(displayField2, viewModel);

            var selectedFields =
                viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>().ToArray();

            // Act / Assert.
            Assert.IsFalse(viewModel.RemoveDisplayFieldCommand.CanExecute(null));
            Assert.IsTrue(viewModel.RemoveDisplayFieldCommand.CanExecute(selectedFields[0]));
            Assert.IsFalse(viewModel.RemoveDisplayFieldCommand.CanExecute(notSelectedField));
        }
        public void MoveDisplayFieldDownCommand_ExecuteTest()
        {
            // Arrange.
            var stepInfo = new StepInfo(123);
            var displayField1 = DisplayListFieldEdit.NewDisplayListFieldEdit();
            displayField1.Order = 1;
            var displayField2 = DisplayListFieldEdit.NewDisplayListFieldEdit();
            displayField2.Order = 2;
            var displayField3 = DisplayListFieldEdit.NewDisplayListFieldEdit();
            displayField3.Order = 3;

            var step = DisplayListRequiredStepEdit.NewStep(123);
            step.SelectedFields.Add(displayField1);
            step.SelectedFields.Add(displayField2);
            step.SelectedFields.Add(displayField3);

            var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose);
            var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField);

            var selectedFields = viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>().ToArray();

            // Act.
            viewModel.MoveDisplayFieldDownCommand.Execute(selectedFields[0]);

            // Assert.
            Assert.IsTrue(step.SelectedFields.OrderBy(f => f.Order).SequenceEqual(new[] { displayField2, displayField1, displayField3 }));
            Assert.IsTrue(
                viewModel.OrderedSelectedFields.View.Cast<ProcessFieldDisplayListRequiredStepViewModel.SelectedFieldViewModel>()
                         .SequenceEqual(new[] { selectedFields[1], selectedFields[0], selectedFields[2] }));
        }
        public void RemoveSortFieldCommand_ExecuteTest()
        {
            // Arrange.
            var stepInfo = new StepInfo(123);
            var sortField1 = DisplayListSortFieldEdit.NewField();
            var sortField2 = DisplayListSortFieldEdit.NewField();
            var step = DisplayListRequiredStepEdit.NewStep(123);
            step.SortFields.Add(sortField1);
            step.SortFields.Add(sortField2);

            var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose);
            var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField);

            // Act.
            viewModel.RemoveSortFieldCommand.Execute(sortField1);

            // Assert.
            Assert.AreEqual(1, step.SortFields.Count);
            Assert.IsFalse(step.SortFields.Contains(sortField1));
        }
        public void AddSortFieldCommand_ExecuteTest()
        {
            // Arrange.
            var stepInfo = new StepInfo(123);
            var step = DisplayListRequiredStepEdit.NewStep(123);
            var parentField = Mock.Create<ProcessFieldViewModel>(Constructor.Mocked, Behavior.Loose);
            var viewModel = new ProcessFieldDisplayListRequiredStepViewModel(step, stepInfo, parentField);

            // Act.
            viewModel.AddSortFieldCommand.Execute(null);
            viewModel.AddSortFieldCommand.Execute(null);
            viewModel.AddSortFieldCommand.Execute(null);

            // Assert.
            Assert.AreEqual(3, step.SortFields.Count);
            Assert.AreEqual(0, step.SortFields[0].Order);
            Assert.AreEqual(1, step.SortFields[1].Order);
            Assert.AreEqual(2, step.SortFields[2].Order);
        }
        public void PopulateUdpTest()
        {
            if (!Mock.IsProfilerEnabled)
                return;

            string filterUDP = string.Format(@"{{
  ""ColumnName"": ""RequireValidationCRSingle_fId"",
  ""Operator"": ""IsEqualTo"",
  ""Value"": ""%{{\""Type\"":\""Udp\"",\""DisplayName\"":\""Value for Require Validation CR Single:\"",\""SystemName\"":\""RequireValidationCRSingle_fId\"",\""DefaultValue\"":2}}%"",
  ""MemberType"": ""Cebos.Veyron.SharedTypes.IInfoClass""
}}");
            var filterDef = new Filter("f", Guid.Empty, filterUDP);

            var pf = new ProcessFieldDisplayListRequiredStepViewModel(
                new DisplayListRequiredStepEdit(), new StepInfo(), new ProcessFieldViewModel(new FieldEdit(), new ProcessSectionViewModel(new SectionEdit()))) { SelectedFilter = filterDef };

            // Act
            Assert.IsNotNull(pf.SelectedFilter);
            Assert.IsNotNull(pf.UdpList);
            Assert.IsNotNull(pf.UdpList[0].Value);
        }
        public void FilterOptionsCommandShouldUpdatProcessFieldAfterPopupIsClosed()
        {
            var filter = Mock.Create<IFilterDescriptor>(Behavior.Loose);
            var stepEdit = DisplayListRequiredStepEdit.NewStep(1);
            stepEdit.SelectedFields = new DisplayListStepFields();

            var processFieldViewModel = new ProcessFieldViewModel(new FieldEdit(), new ProcessSectionViewModel(Mock.Create<ISectionEdit>()));

            var vm = new ProcessFieldDisplayListRequiredStepViewModel(stepEdit, new StepInfo(1), processFieldViewModel);

            Mock.Arrange(() => vm.GetProcessedFilter()).IgnoreInstance().Returns(Mock.Create<IFilterDescriptor>());

            var processEdit = Mock.Create<ProcessEdit>(Behavior.Loose);
            var fieldsViewModel = new ProcessFieldsViewModel { Model = processEdit };
            vm.Model = fieldsViewModel;

            var popupFactory = Mock.Create<PopupFactory>(Behavior.Loose);
            var popupBuilder = Mock.Create<PopupBuilder>(Behavior.CallOriginal);
            Mock.Arrange(() => popupFactory.Popup()).Returns(popupBuilder);
            Mock.Arrange(() => popupBuilder.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).DoInstead((Action ok, Action cancel) => ok());
            vm.ThePopupFactory = popupFactory;

            var filterOptions = Mock.Create<FilterOptionsViewModel>(Behavior.Loose);
            vm.FilterOptionsVM = new Lazy<FilterOptionsViewModel>(() => filterOptions);

            var procField = new ProcessField("test", "test");
            filterOptions.IsProcessField = true;
            filterOptions.SelectedProcessField = procField;

            var filterValue = new FilterValue { Type = FilterValueType.ProcessField };
            Mock.Arrange(() => filter.Value).Returns(filterValue);

            vm.FilterOptionsCommand.Execute(filter);
            Assert.AreEqual("FLD: test", filterValue.ProvidedValue.ToString());

            Mock.Arrange(() => filter.Value).Returns((FilterValue)null);
            vm.FilterOptionsCommand.Execute(filter);
            Mock.AssertSet(() => filter.Value = Arg.IsAny<FilterValue>());
        }