Ejemplo n.º 1
0
        public void NotifyPropertyChangedTests()
        {
            // Arrange.
            var screenMock = Mock.Create<IFieldSecurityManager>();

            var field = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => field.StepList).Returns(() => new StepEditList());
            

            var processMock = Mock.Create<ProcessEdit>();
            var vm = new ExpandableStepPropBag(processMock) { FieldSecurityManager = screenMock, Model = field };

            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.IsVisible);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.IsEditable);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Label);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.CopyItemButtonIsEnabled);
        }
Ejemplo n.º 2
0
        public void FieldSecurityTests()
        {
            var screenMock = Mock.Create<IFieldSecurityManager>();

            var field = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => field.StepList).Returns(() => new StepEditList());

            var processMock = Mock.Create<ProcessEdit>();
            var vm = new ExpandableStepPropBag(processMock) { FieldSecurityManager = screenMock, Model = field, IsEditable = true };

            Assert.IsTrue(vm.IsEditable);

            vm.IsEditable = false;
            Assert.IsFalse(vm.IsEditable);

            vm.IsVisible = true;
            Assert.IsTrue(vm.IsVisible);

            vm.IsVisible = false;
            Assert.IsFalse(vm.IsVisible);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the field.
        /// </summary>
        /// <param name="sectionId">The section identifier.</param>
        /// <param name="parentModel">The parent model.</param>
        /// <param name="f">The f.</param>
        public void AddField(int sectionId, BusinessBase parentModel, FieldEdit f)
        {
            foreach (var step in f.StepList)
            {
                step.AddProps();
            }

            var expandableObj = new ExpandableStepPropBag(parentModel) { FieldSecurityManager = ProcessScreenSecuritySettings, Model = f };
            foreach (var step in f.StepList)
            {
                step.UpdateProps(expandableObj);
            }

            expandableObj.PreviewMode = true;

            //if (expandableObj.SectionId == sectionId)
            {
                Fields.Add(expandableObj);
                FieldList.Add(f);
            }
        }
Ejemplo n.º 4
0
        [TestMethod]
        public void SetupCopyItemButtonWhenFieldIsReverseReference_GetPublishedProcessesAsync_ReturnFour_4()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var model = Mock.Create<FieldEdit>(Behavior.CallOriginal);

            var rcrStepEdit = Mock.Create<ReverseCrossRefRequiredStepEdit>(Behavior.CallOriginal);
            rcrStepEdit.DisplayMultiple = true;
            const int id = 1;
            rcrStepEdit.ReverseCrossRefProcess = CreatePublishedProcess(id);
            rcrStepEdit.CrossRefFieldName = "ResponsibilityPerson_f";

            Mock.Arrange(() => rcrStepEdit.IsChild).Returns(true);

            Mock.Arrange(() => model.StepList).Returns(new StepEditList { rcrStepEdit });
            Mock.Arrange(() => expandableStep.Model).Returns(model);

            var publishedProcesses = new PublishedProcessesMock(new List<PublishedProcessInfo> { new PublishedProcessInfo { Id = id } });

            Mock.Arrange(() => PublishedProcesses.GetPublishedProcessesAsync(Arg.IsAny<ReverseCrossRefProcessCriteria>()))
                .Returns(() =>
                {
                    var tcs = new TaskCompletionSource<PublishedProcesses>();
                    tcs.SetResult(publishedProcesses);
                    return tcs.Task;
                });

            try
            {
                // act
                new PrivateAccessor(expandableStep).CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });
            }
            catch (Exception ex)
            {
                // assert
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }
Ejemplo n.º 5
0
        public void PopulateFields(SectionEdit section)
        {
            foreach (var field in section.FieldList.OrderBy(f => f.Position))
            {
                if (field == null) continue;
                var fieldVM = FieldFactory.CreateFieldVM(field, this);
                FieldList.Add(fieldVM);

                foreach (var step in field.StepList)
                    step.AddProps();

                var expandableObj = new ExpandableStepPropBag(TheProcessFieldsViewModel.Model) { FieldSecurityManager = TheProcessFieldsViewModel, Model = field, PreviewMode = true };

                foreach (var step in field.StepList)
                    step.UpdateProps(expandableObj);

                expandableObj.PreviewMode = true;

                if (!TheProcessFieldsViewModel.FieldList.Keys.Contains(field.Guid))
                    TheProcessFieldsViewModel.FieldList.Add(field.Guid, new Tuple<ProcessFieldViewModel, ExpandableStepPropBag>(fieldVM, expandableObj));

                Fields.Add(expandableObj);
            }

            SortFields();
        }
Ejemplo n.º 6
0
        [TestMethod]
        public void SetupCopyItemButtonWhenFieldIsReverseReference_FirstReturns()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var model = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => model.StepList).Returns(new StepEditList());

            Mock.Arrange(() => expandableStep.Model).Returns(model);

            var privateAccessor = new PrivateAccessor(expandableStep);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });
            
            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            var rcrStepEdit = Mock.Create<ReverseCrossRefRequiredStepEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => rcrStepEdit.IsChild).Returns(true);
            Mock.Arrange(() => model.StepList).Returns(new StepEditList { rcrStepEdit });

            Mock.Arrange(() => rcrStepEdit.ReverseCrossRefProcessId).Throws<Exception>();

            try
            {
                // act
                privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });
            }
            catch (Exception ex)
            {
                // assert
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }

            // arrange
            rcrStepEdit.DisplayMultiple = true;
            Mock.Arrange(() => rcrStepEdit.ReverseCrossRefProcessId).Returns((int?)null);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            Mock.Arrange(() => rcrStepEdit.ReverseCrossRefProcessId).Returns(1);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);
Ejemplo n.º 7
0
        [TestMethod]
        public void PopulateProperties()
        {
            // arrange
            var expandableStep = new ExpandableStepPropBag(null);

            var fieldEdit = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => expandableStep.Model).Returns(fieldEdit);

            fieldEdit.CopyFieldValueOnCopyItem = true;

            var raises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "CopyFieldValueOnCopyItem").DoInstead(() => { raises = true; });

            // act
            expandableStep.Model = fieldEdit;

            // assert
            Assert.IsTrue(raises);
            Assert.IsTrue(expandableStep.CopyFieldValueOnCopyItem);
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            parentModel.ProcessOptionChoose = ProcessOption.None;

            expandableStep = new ExpandableStepPropBag(parentModel);
            Mock.Arrange(() => expandableStep.Model).Returns(fieldEdit);

            // act
            expandableStep.Model = fieldEdit;

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            parentModel.ProcessOptionChoose = ProcessOption.VersionEnabled;

            // act
            expandableStep.Model = fieldEdit;

            // assert
            Assert.IsTrue(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            parentModel.ProcessOptionChoose = ProcessOption.SchedulingEnabled;

            var called = false;
            Mock.NonPublic.Arrange(expandableStep, "SetupCopyItemButtonWhenProcessSupportScheduling").DoInstead(() => called = true);

            // act
            expandableStep.Model = fieldEdit;

            // assert
            Assert.IsTrue(called);
Ejemplo n.º 8
0
        [TestMethod]
        public void CanSetFieldEditabilityProperty()
        {
            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var fieldSecurityManager = Mock.Create<IFieldSecurityManager>(Behavior.Loose);
            expandableStep.FieldSecurityManager = fieldSecurityManager;

            // act
            var result = expandableStep.CanSetFieldEditability;

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => fieldSecurityManager.IsSecurityMode).Returns(true);
            Mock.Arrange(() => parentModel.SecurityConfigList).Returns(new ProcessSecurityConfigEditList());

            // act
            result = expandableStep.CanSetFieldEditability;

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => fieldSecurityManager.IsSecurityMode).Returns(true);

            var processSecurityConfigEdit = Mock.Create<ProcessSecurityConfigEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => processSecurityConfigEdit.IsChild).Returns(true);

            Mock.Arrange(() => parentModel.SecurityConfigList).Returns(new ProcessSecurityConfigEditList { processSecurityConfigEdit });

            parentModel.SystemName = Constants.FileProcessName;

            // act
            result = expandableStep.CanSetFieldEditability;

            // assert
            Assert.IsFalse(result);

            // arrange
            parentModel.SystemName = "eCar_p";

            // act
            result = expandableStep.CanSetFieldEditability;

            // assert
            Assert.IsTrue(result);
Ejemplo n.º 9
0
        [TestMethod]
        public void UpdateIsRequiredVisibility()
        {
            // arrange
            var expandableStep = new ExpandableStepPropBag(null);

            var called = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "ShowIsRequired").DoInstead(() => called = true);

            // act
            expandableStep.UpdateIsRequiredVisibility();

            // assert
            Assert.IsTrue(called);
Ejemplo n.º 10
0
        [TestMethod]
        public void SetIsRequired()
        {
            // arrange
            var expandableStep = new ExpandableStepPropBag(null);

            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsRequired").Throws<Exception>();

            try
            {
                // act
                expandableStep.SetIsRequired(false);
            }
            catch (Exception ex)
            {
                // assert
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }

            // arrange
            var called = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsRequired").DoInstead(() => called = true);

            // act
            expandableStep.SetIsRequired(true);

            // assert
            Assert.IsTrue((bool)new PrivateAccessor(expandableStep).GetField("_isRequired"));
            Assert.IsTrue(called);
Ejemplo n.º 11
0
        [TestMethod]
        public void WhenModelChildIsChanged_PropertiesAreUpdated()
        {
            // Arrange.
            var screenMock = Mock.Create<IFieldSecurityManager>();

            var field = new FieldEditMock();

            var processMock = Mock.Create<ProcessEdit>();

            var steps = new List<IStepEdit>();

            var stepMock = Mock.Create<IStepEdit>();
            Mock.Arrange(() => stepMock.IsChild).Returns(true);
            steps.Add(stepMock);

            stepMock = Mock.Create<IStepEdit>();
            Mock.Arrange(() => stepMock.IsChild).Returns(true);
            steps.Add(stepMock);

            stepMock = Mock.Create<IStepEdit>();
            Mock.Arrange(() => stepMock.IsChild).Returns(true);
            steps.Add(stepMock);

            field.StepList.AddRange(steps);

            var vm = new ExpandableStepPropBag(processMock) { FieldSecurityManager = screenMock, Model = field };

            field.RaiseChildChanged();

            foreach (var mock in steps)
            {
                Mock.Assert(() => mock.UpdateProps(vm), Occurs.Once());
            }
Ejemplo n.º 12
0
        [TestMethod]
        public void SetSecurity()
        {
            // arrange
            var expandableStep = new ExpandableStepPropBag(null);

            var isVisibleRaises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsVisible").DoInstead(() => isVisibleRaises = true);

            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsEditable").Throws<Exception>();

            try
            {
                // act
                expandableStep.SetSecurity(true, null);
            }
            catch (Exception ex)
            {
                // assert
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }

            // assert
            Assert.IsTrue(isVisibleRaises);

            try
            {
                // act
                expandableStep.SetSecurity(true, false);
            }
            catch (Exception ex)
            {
                // assert
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }

            // arrange
            var isEditableRaises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsEditable").DoInstead(() => isEditableRaises = true);

            // act
            expandableStep.SetSecurity(true, true);

            Assert.IsTrue(isEditableRaises);
Ejemplo n.º 13
0
        [TestMethod]
        public void ModelPropertyChanged()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var model = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            model.FieldType = new FieldTypeInfo();
            Mock.Arrange(() => model.StepList).Returns(new StepEditList());
            Mock.Arrange(() => expandableStep.Model).Returns(model);

            var fieldSecurityManager = Mock.Create<IFieldSecurityManager>(Behavior.CallOriginal);
            expandableStep.FieldSecurityManager = fieldSecurityManager;

            var clearRequiredRulesWasCalled = false;
            Mock.Arrange(() => fieldSecurityManager.ClearRequiredRules(Arg.AnyGuid)).DoInstead(() => clearRequiredRulesWasCalled = true);

            var setIsRequiredWasCalled = false;
            Mock.Arrange(() => expandableStep.SetIsRequired(false)).DoInstead(() => setIsRequiredWasCalled = true);

            // act
            new PrivateAccessor(expandableStep).CallMethod("ModelPropertyChanged", new[] { new object(), new PropertyChangedEventArgs("FieldType") });

            // assert
            Assert.IsTrue(clearRequiredRulesWasCalled);
            Assert.IsTrue(setIsRequiredWasCalled);
Ejemplo n.º 14
0
        [TestMethod]
        public void SetupCopyItemButtonWhenProcessSupportScheduling_GetCrossRefFieldList()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var model = Mock.Create<FieldEdit>(Behavior.CallOriginal);

            var rcrStepEdit = Mock.Create<ReverseCrossRefRequiredStepEdit>(Behavior.CallOriginal);
            rcrStepEdit.DisplayMultiple = true;
            const int id = 1;
            rcrStepEdit.ReverseCrossRefProcess = CreatePublishedProcess(id);
            const string fieldName = "ResponsibilityPerson_f";
            rcrStepEdit.CrossRefFieldName = fieldName;

            Mock.Arrange(() => rcrStepEdit.IsChild).Returns(true);

            Mock.Arrange(() => model.StepList).Returns(new StepEditList { rcrStepEdit });
            Mock.Arrange(() => expandableStep.Model).Returns(model);

            var publishedProcess = Mock.Create<PublishedProcessInfo>();
            publishedProcess.Id = 1;
            const int otherProcessId = 2;
            Mock.Arrange(() => publishedProcess.ProcessId).Returns(otherProcessId);

            var publishedProcesses = new PublishedProcessesMock(new List<PublishedProcessInfo> { publishedProcess });
            var task = new Task<PublishedProcesses>(() => publishedProcesses);
            task.Start();

            Mock.Arrange(() => PublishedProcesses.GetPublishedProcessesAsync(Arg.IsAny<ReverseCrossRefProcessCriteria>())).Returns(task);

            Mock.Arrange(() => CrossRefFieldList.GetCrossRefFieldList(2, Arg.AnyGuid, Arg.IsAny<EventHandler<DataPortalResult<CrossRefFieldList>>>())).
                DoInstead((int processId, Guid parentProcessGuid, EventHandler<DataPortalResult<CrossRefFieldList>> callback) =>
                    callback(null, new DataPortalResult<CrossRefFieldList>(null, new Exception(), null)));

            var privateAccessor = new PrivateAccessor(expandableStep);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            Mock.Arrange(() => CrossRefFieldList.GetCrossRefFieldList(2, Arg.AnyGuid, Arg.IsAny<EventHandler<DataPortalResult<CrossRefFieldList>>>())).
                DoInstead((int processId, Guid parentProcessGuid, EventHandler<DataPortalResult<CrossRefFieldList>> callback) =>
                    callback(null, new DataPortalResult<CrossRefFieldList>(new CrossRefFieldList(), null, null)));

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            Mock.Arrange(() => CrossRefFieldList.GetCrossRefFieldList(2, Arg.AnyGuid, Arg.IsAny<EventHandler<DataPortalResult<CrossRefFieldList>>>())).
                DoInstead((int processId, Guid parentProcessGuid, EventHandler<DataPortalResult<CrossRefFieldList>> callback) =>
                    callback(null, new DataPortalResult<CrossRefFieldList>(new CrossRefFieldListMock(new List<CrossRefFieldInfo> { Mock.Create<CrossRefFieldInfo>(Behavior.CallOriginal) }), null, null)));

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            var crossRefFieldInfo1 = Mock.Create<CrossRefFieldInfo>(Behavior.CallOriginal);
            Mock.Arrange(() => crossRefFieldInfo1.SystemName).Returns("eCarNumber_f");

            var crossRefFieldInfo2 = Mock.Create<CrossRefFieldInfo>(Behavior.CallOriginal);
            Mock.Arrange(() => crossRefFieldInfo2.SystemName).Returns(fieldName);

            Mock.Arrange(() => CrossRefFieldList.GetCrossRefFieldList(2, Arg.AnyGuid, Arg.IsAny<EventHandler<DataPortalResult<CrossRefFieldList>>>())).
                DoInstead((int processId, Guid parentProcessGuid, EventHandler<DataPortalResult<CrossRefFieldList>> callback) =>
                    callback(null, new DataPortalResult<CrossRefFieldList>(new CrossRefFieldListMock(new List<CrossRefFieldInfo> { crossRefFieldInfo1, crossRefFieldInfo2 }), null, null)));

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            Mock.Arrange(() => crossRefFieldInfo2.AllowMany).Returns(true);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsTrue(expandableStep.CopyItemButtonIsEnabled);
Ejemplo n.º 15
0
        [TestMethod]
        public void ShowDeepCopyControl()
        {
            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            // act
            var result = expandableStep.ShowDeepCopyControl;

            // assert
            Assert.IsFalse(result);

            // arrange
            parentModel.ProcessOptionChoose = ProcessOption.VersionEnabled;

            var fieldEdit = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            var fieldType = Mock.Create<FieldTypeInfo>(Behavior.CallOriginal);
            fieldEdit.FieldType = fieldType;
            Mock.Arrange(() => expandableStep.Model).Returns(fieldEdit);

            // act
            result = expandableStep.ShowDeepCopyControl;

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => fieldEdit.FieldType.ColumnType).Returns(ColumnTypes.Reference);
            Mock.Arrange(() => fieldEdit.StepList).Returns(new StepEditList());

            // act
            result = expandableStep.ShowDeepCopyControl;

            // assert
            Assert.IsFalse(result);

            // arrange
            var stepEdit = Mock.Create<CrossRefRequiredStepEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => stepEdit.IsChild).Returns(true);
            Mock.Arrange(() => fieldEdit.StepList).Returns(new StepEditList { stepEdit });

            // act
            result = expandableStep.ShowDeepCopyControl;

            // assert
            Assert.IsFalse(result);

            // arrange
            stepEdit.AllowMultiple = true;

            // act
            result = expandableStep.ShowDeepCopyControl;

            // assert
            Assert.IsTrue(result);
Ejemplo n.º 16
0
        [TestMethod]
        public void DeepCopyProperty()
        {
            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var fieldEdit = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => expandableStep.Model).Returns(fieldEdit);

            var raises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "DeepCopy").DoInstead(() => { raises = true; });

            // act
            expandableStep.DeepCopy = true;

            // assert
            Assert.IsTrue(raises);
            Assert.IsTrue(expandableStep.DeepCopy);

            // arrange
            raises = false;

            // act
            expandableStep.DeepCopy = true;

            Assert.IsFalse(raises);
Ejemplo n.º 17
0
        [TestMethod]
        public void RefreshSecurityPermissions()
        {
            // arrange
            var expandableStep = new ExpandableStepPropBag(null);

            var isVisibleRaises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsVisible").DoInstead(() => { isVisibleRaises = true; });

            var isEditableRaises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsEditable").DoInstead(() => { isEditableRaises = true; });

            var canSetFieldVisibilityRaises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "CanSetFieldVisibility").DoInstead(() => { canSetFieldVisibilityRaises = true; });

            var canSetFieldEditabilityRaises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "CanSetFieldEditability").DoInstead(() => { canSetFieldEditabilityRaises = true; });

            // act
            expandableStep.RefreshSecurityPermissions();

            // assert
            Assert.IsTrue(isVisibleRaises);
            Assert.IsTrue(isEditableRaises);
            Assert.IsTrue(canSetFieldVisibilityRaises);
            Assert.IsTrue(canSetFieldEditabilityRaises);
Ejemplo n.º 18
0
        [TestMethod]
        public void CopyFieldTooltipProperty()
        {
            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            // act
            var result = expandableStep.CopyFieldTooltip;

            // assert
            Assert.AreEqual("copy into the new version", result);

            // arrange
            parentModel.ProcessOptionChoose = ProcessOption.SchedulingEnabled;

            // act
            result = expandableStep.CopyFieldTooltip;

            // assert
            Assert.AreEqual("copy for scheduled items", result);

            // arrange
            parentModel.ProcessOptionChoose = ProcessOption.VersionEnabled;

            // act
            result = expandableStep.CopyFieldTooltip;

            // assert
            Assert.AreEqual("copy into the new version", result);
Ejemplo n.º 19
0
        [TestMethod]
        public void ValueProperty()
        {
            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var value = new object();

            var property = Mock.Create<PropertyInfo>(Behavior.CallOriginal);
            expandableStep.Property = property;

            var setValueWasCalled = false;
            Mock.Arrange(() => property.SetValue(parentModel, value, null)).DoInstead(() => setValueWasCalled = true);

            var raises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "Value").DoInstead(() => { raises = true; });

            // act
            expandableStep.Value = value;

            // assert
            Assert.IsTrue(setValueWasCalled);
            Assert.IsTrue(raises);
            Assert.AreEqual(value, expandableStep.Value);

            // arrange
            setValueWasCalled = false;
            raises = false;

            expandableStep.PreviewMode = true;

            value = new object();

            // act
            expandableStep.Value = value;

            // assert
            Assert.IsFalse(setValueWasCalled);
            Assert.IsTrue(raises);

            // arrange
            setValueWasCalled = false;
            raises = false;

            // act
            expandableStep.Value = value;

            // assert
            Assert.IsFalse(setValueWasCalled);
            Assert.IsFalse(raises);
Ejemplo n.º 20
0
        [TestMethod]
        public void CanEditProperty()
        {
            // arrange
            var expandableStep = new ExpandableStepPropBag(null)
                {
                    PreviewMode = true
                };

            // act
            var result = expandableStep.CanEdit;

            // assert
            Assert.IsTrue(result);

            // arrange
            expandableStep.PreviewMode = false;

            // act
            result = expandableStep.CanEdit;

            // assert
            Assert.IsFalse(result);

            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            expandableStep = new ExpandableStepPropBag(parentModel)
                {
                    Property = Mock.Create<PropertyInfo>(Behavior.Loose)
                };

            // act
            result = expandableStep.CanEdit;

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => parentModel.CanWriteProperty(Arg.AnyString)).Returns(true);

            // act
            result = expandableStep.CanEdit;

            // assert
            Assert.IsTrue(result);
Ejemplo n.º 21
0
        [TestMethod]
        public void Test()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.CallOriginal);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var property = Mock.Create<PropertyInfo>(Behavior.CallOriginal);

            // act
            expandableStep.Property = property;

            // assert
            Assert.AreEqual(property, expandableStep.Property);

            // act
            expandableStep.FieldType = "abc";

            // assert
            Assert.AreEqual("abc", expandableStep.FieldType);

            // act
            expandableStep.SectionId = 1;

            // assert
            Assert.AreEqual(1, expandableStep.SectionId);

            // act
            expandableStep.PreviewMode = true;

            // assert
            Assert.IsTrue(expandableStep.PreviewMode);

            // act
            expandableStep.Label = "hello";

            // assert
            Assert.AreEqual("hello", expandableStep.Label);
Ejemplo n.º 22
0
        [TestMethod]
        public void SetupCopyItemButtonWhenProcessSupportScheduling1()
        {
            // arrange
            var parentModel = Mock.Create<ProcessEdit>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var privateAccessor = new PrivateAccessor(expandableStep);

            try
            {
                // act
                privateAccessor.CallMethod("SetupCopyItemButtonWhenProcessSupportScheduling");
            }
            catch (Exception ex)
            {
                // assert
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }

            // arrange
            var schedule = Mock.Create<ProcessScheduleEdit>(Behavior.CallOriginal);
            schedule.ScheduleKeyField = "KeyField_f";

            parentModel.Schedule = schedule;

            var fieldEdit = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            fieldEdit.SystemName = "KeyField_f";
            Mock.Arrange(() => expandableStep.Model).Returns(fieldEdit);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenProcessSupportScheduling");

            // assert
            Assert.IsTrue(expandableStep.CopyFieldValueOnCopyItem);

            // arrange
            schedule.ScheduleBasedOnDateField = "DueDate_f";
            fieldEdit.SystemName = "DueDate_f";

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenProcessSupportScheduling");

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            schedule.ScheduleDisplayDateField = "DisplayNextDate_f";
            fieldEdit.SystemName = "DisplayNextDate_f";

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenProcessSupportScheduling");

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            fieldEdit.SystemName = "Notes_f";

            var fieldType = Mock.Create<FieldTypeInfo>(Behavior.CallOriginal);
            Mock.Arrange(() => fieldType.ColumnType).Returns(ColumnTypes.ReverseReference);

            fieldEdit.FieldType = fieldType;

            var called = false;
            Mock.NonPublic.Arrange(expandableStep, "SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Arg.AnyGuid }).DoInstead(() => called = true);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenProcessSupportScheduling");

            // assert
            Assert.IsTrue(called);
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);

            // arrange
            Mock.Arrange(() => fieldType.ColumnType).Returns(ColumnTypes.String);

            // act
            privateAccessor.CallMethod("SetupCopyItemButtonWhenProcessSupportScheduling");

            // assert
            Assert.IsTrue(expandableStep.CopyItemButtonIsEnabled);
Ejemplo n.º 23
0
        [TestMethod]
        public void ModelProperty()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.CallOriginal);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var fieldEdit = Mock.Create<FieldEdit>(Behavior.CallOriginal);

            var populatePropertiesWasCalled = false;
            Mock.NonPublic.Arrange(expandableStep, "PopulateProperties").DoInstead(() => populatePropertiesWasCalled = true);

            // act
            expandableStep.Model = fieldEdit;

            // assert
            Assert.IsTrue(populatePropertiesWasCalled);
            Assert.AreEqual(fieldEdit, expandableStep.Model);

            // arrange
            populatePropertiesWasCalled = false;

            // act
            expandableStep.Model = null;

            // assert
            Assert.IsFalse(populatePropertiesWasCalled);
Ejemplo n.º 24
0
        private ExpandableStepPropBag CreateExpandableObject(FieldEdit field)
        {
            var expandableObj = new ExpandableStepPropBag(TheProcessFieldsViewModel.Model) { FieldSecurityManager = TheProcessFieldsViewModel, Model = field, PreviewMode = true };

            foreach (var step in field.StepList)
                step.UpdateProps(expandableObj);

            expandableObj.PreviewMode = true;

            return expandableObj;
        }
Ejemplo n.º 25
0
        [TestMethod]
        public void IsRequiredProperty()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.CallOriginal);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var guid = Guid.NewGuid();
            var fieldEdit = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            fieldEdit.Guid = guid;

            Mock.Arrange(() => expandableStep.Model).Returns(fieldEdit);

            var called = false;
            var fieldSecurityManager = Mock.Create<IFieldSecurityManager>(Behavior.CallOriginal);
            Mock.Arrange(() => fieldSecurityManager.SetFieldIsRequired(true, guid)).DoInstead(() => called = true);

            expandableStep.FieldSecurityManager = fieldSecurityManager;

            var raises = false;
            Mock.NonPublic.Arrange(expandableStep, "RaisePropertyChanged", "IsRequired").DoInstead(() => { raises = true; });

            // act
            expandableStep.IsRequired = true;

            // assert
            Assert.IsTrue(called);
            Assert.IsTrue(raises);
            Assert.IsTrue(expandableStep.IsRequired);

            // arrange
            called = false;
            raises = false;

            // act
            expandableStep.IsRequired = true;

            // assert
            Assert.IsFalse(called);
            Assert.IsFalse(raises);
Ejemplo n.º 26
0
        [TestMethod]
        public void ShowIsRequired()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.CallOriginal);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var fieldEdit = Mock.Create<FieldEdit>(Behavior.CallOriginal);
            Mock.Arrange(() => expandableStep.Model).Returns(fieldEdit);

            var fieldSecurityManager = Mock.Create<IFieldSecurityManager>(Behavior.CallOriginal);
            Mock.Arrange(() => fieldSecurityManager.ShowIsRequired).Returns(false);
            expandableStep.FieldSecurityManager = fieldSecurityManager;

            // act
            var result = expandableStep.ShowIsRequired;

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => fieldSecurityManager.ShowIsRequired).Returns(true);

            // act
            result = expandableStep.ShowIsRequired;

            // assert
            Assert.IsFalse(result);

            // arrange
            var fieldTypeInfo = Mock.Create<FieldTypeInfo>();
            Mock.Arrange(() => fieldEdit.With(Arg.IsAny<Func<FieldEdit, FieldTypeInfo>>())).Returns(fieldTypeInfo);

            // act
            result = expandableStep.ShowIsRequired;

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => fieldTypeInfo.CanBeRequired).Returns(true);

            // act
            result = expandableStep.ShowIsRequired;

            // assert
            Assert.IsTrue(result);
Ejemplo n.º 27
0
        [TestMethod]
        public void SetupCopyItemButtonWhenFieldIsReverseReference_GetPublishedProcessesAsync_ReturnTwo_4()
        {
            // arrange
            var parentModel = Mock.Create<BusinessBase>(Behavior.Loose);
            var expandableStep = new ExpandableStepPropBag(parentModel);

            var model = Mock.Create<FieldEdit>(Behavior.CallOriginal);

            var rcrStepEdit = Mock.Create<ReverseCrossRefRequiredStepEdit>(Behavior.CallOriginal);
            rcrStepEdit.DisplayMultiple = true;
            const int id = 1;
            rcrStepEdit.ReverseCrossRefProcess = CreatePublishedProcess(id);
            rcrStepEdit.CrossRefFieldName = "ResponsibilityPerson_f";

            Mock.Arrange(() => rcrStepEdit.IsChild).Returns(true);

            Mock.Arrange(() => model.StepList).Returns(new StepEditList { rcrStepEdit });
            Mock.Arrange(() => expandableStep.Model).Returns(model);

            Mock.Arrange(() => PublishedProcesses.GetPublishedProcessesAsync(Arg.IsAny<ReverseCrossRefProcessCriteria>()))
                .Returns(() => new TaskCompletionSource<PublishedProcesses>().Task);

            // act
            new PrivateAccessor(expandableStep).CallMethod("SetupCopyItemButtonWhenFieldIsReverseReference", new object[] { Guid.Empty });

            // assert
            Assert.IsFalse(expandableStep.CopyItemButtonIsEnabled);