コード例 #1
0
        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);
        }