[Ignore]//TODO: Unignore public void PopulateFields_Test() { const int basePersonProcessId = 1; const int baseBusinessUnitProcessId = 2; const string personFieldName = "Person"; const string buFieldName = "BusinessUnits"; var basePersonProcessInfo = Mock.Create<PublishedProcessInfo>(); Mock.Arrange(() => basePersonProcessInfo.Id).Returns(basePersonProcessId); Mock.Arrange(() => basePersonProcessInfo.SystemName).Returns(Constants.BasePersonProcessName); var baseBUProcessInfo = Mock.Create<PublishedProcessInfo>(); Mock.Arrange(() => baseBUProcessInfo.Id).Returns(baseBusinessUnitProcessId); Mock.Arrange(() => baseBUProcessInfo.SystemName).Returns(Constants.BaseBusinessUnitProcessName); var crossRefStep = DataPortal.CreateChild<CrossRefRequiredStepEdit>(); crossRefStep.CrossRefProcess = basePersonProcessInfo; var personField = DataPortal.CreateChild<FieldEdit>(); personField.SystemName = personFieldName; personField.StepList.Add(crossRefStep); personField.FieldType = new FieldTypeInfoMock("Reference", "Reference"); crossRefStep = DataPortal.CreateChild<CrossRefRequiredStepEdit>(); crossRefStep.CrossRefProcess = baseBUProcessInfo; var buField = DataPortal.CreateChild<FieldEdit>(); buField.SystemName = buFieldName; buField.StepList.Add(crossRefStep); buField.FieldType = new FieldTypeInfoMock("MultiReference", "MultiReference"); var sectionEdit = DataPortal.CreateChild<SectionEdit>(); sectionEdit.FieldList.Add(personField); sectionEdit.FieldList.Add(buField); var sectionList = new ProcessSections {sectionEdit}; var processEditMock = Mock.Create<ProcessEdit>(); Mock.Arrange(() => processEditMock.SectionList).Returns(sectionList); var uow = new ProcessEditRetrieverMock(processEditMock, new[] { basePersonProcessInfo, baseBUProcessInfo }); var approvalStep = DataPortal.CreateChild<ApprovalOptionsStepEdit>(); var stepInfo = Mock.Create<StepInfo>(); var fieldEdit = DataPortal.CreateChild<FieldEdit>(); var fieldVM = new ProcessFieldViewModel(fieldEdit, null); var fieldsVM = new ProcessFieldsViewModel { Model = processEditMock, UnitOfWork = uow }; var vm = new ProcessFieldApprovalOptionsStepViewModel(approvalStep, stepInfo, fieldVM) { Model = fieldsVM }; Assert.IsNotNull(vm.SortedLevels); Assert.IsNotNull(vm.Roles); Assert.IsNotNull(vm.ApprovalMembersFields); Assert.IsNotNull(vm.BusinessUnitFields); var eventAggregatorMock = Mock.Create<IEventAggregator>(); vm.EventAggregator = eventAggregatorMock; var role1Mock = Mock.Create<IRoleInfo>(); Mock.Arrange(() => role1Mock.Id).Returns(3); var role2Mock = Mock.Create<IRoleInfo>(); Mock.Arrange(() => role2Mock.Id).Returns(5); var roles = new List<IRoleInfo> { role1Mock, role2Mock }; var organizationInfoMock = Mock.Create<IOrganizationInfo>(); Mock.Arrange(() => organizationInfoMock.Roles).Returns(roles); var processfieldsVMMock = Mock.Create<ProcessFieldsViewModel>(); vm.OrganizationInfo = organizationInfoMock; vm.TheProcessFieldsVM = processfieldsVMMock; vm.OnImportsSatisfied(); Assert.AreEqual(2, vm.ApprovalMembersFields.Count); Assert.IsTrue(vm.ApprovalMembersFields.Any(f => f.SystemName == personField.SystemName)); Assert.AreEqual(2, vm.BusinessUnitFields.Count); Assert.IsTrue(vm.BusinessUnitFields.Any(f => f.SystemName == buField.SystemName)); Assert.AreEqual(3, vm.Roles.Count); Assert.IsTrue(vm.Roles.Any(r => r.Id == role1Mock.Id)); Assert.IsTrue(vm.Roles.Any(r => r.Id == role2Mock.Id)); }
public void RemoveFieldDoNotPersistLayoutChangingIfTheFieldIsMovingToAnotherSection() { var section = new ProcessSectionViewModel(new SectionEdit()) { TheProcessFieldsViewModel = new ProcessFieldsViewModel { Model = Mock .Create<ProcessEdit>() } }; var sectionList = new ProcessSections(); var sectionFields = new ObservableCollection<ExpandableStepPropBag>(); Mock.Arrange(() => section.Fields).Returns(sectionFields); Mock.Arrange(() => sectionList.RemoveField(Arg.IsAny<FieldEdit>())).DoNothing(); Mock.Arrange(() => section.TheProcessFieldsViewModel.Model.SectionList).Returns(sectionList); var processFieldList = new Dictionary<Guid, Tuple<ProcessFieldViewModel, ExpandableStepPropBag>>(); Mock.Arrange(() => section.TheProcessFieldsViewModel.FieldList).Returns(processFieldList); var field = new ProcessFieldViewModel(new FieldEdit(), section); var eventCalled = false; Mock.Arrange(() => section.EventAggregator.Publish(Arg.IsAny<FieldListChangedEvent>())).DoInstead(() => eventCalled = true); section.RemoveField(field); Assert.IsTrue(eventCalled); eventCalled = false; section.RemoveField(field, true); Assert.IsFalse(eventCalled); }