コード例 #1
0
        public void LockSortAndGroupControls()
        {
            // arrange
            Mock.Arrange(() => new LayoutSetupViewModel()).DoNothing();
            var vm = new LayoutSetupViewModel();

            var column = Mock.Create<GridColumnViewModel>(Behavior.CallOriginal);
            column.CanChangeGroupLevel = true;
            column.CanChangeSortDirection = true;
            column.CanChangeSortLevel = true;

            Mock.Arrange(() => vm.AvailableFields).Returns(new ObservableCollection<GridColumnViewModel>());
            vm.AvailableFields.Add(column);

            var field = Mock.Create<GridColumnViewModel>(Behavior.CallOriginal);
            field.CanChangeGroupLevel = true;
            field.CanChangeSortDirection = true;
            field.CanChangeSortLevel = true;

            Mock.Arrange(() => vm.Columns).Returns(new ObservableCollection<IGridColumn>());
            vm.Columns.Add(field);

            // act
            vm.LockSortAndGroupControls();

            // assert
            Assert.IsFalse(column.CanChangeGroupLevel);
            Assert.IsFalse(column.CanChangeSortDirection);
            Assert.IsFalse(column.CanChangeSortLevel);

            Assert.IsFalse(field.CanChangeGroupLevel);
            Assert.IsFalse(field.CanChangeSortDirection);
            Assert.IsFalse(field.CanChangeSortLevel);
        }
コード例 #2
0
        public void ValidateName_WhenNameIsEmpty_AddsToErrors()
        {
            //Arrange
            var classUnderTest = new LayoutSetupViewModel();
            classUnderTest.Name = string.Empty;

            //Act
            classUnderTest.ValidateName();

            //Assert
            var errors = (ICollection)classUnderTest.GetErrors("Name");
            Assert.AreEqual(1, errors.Count);
        }
コード例 #3
0
        /// <summary>
        /// Columns_s the collection changed.
        /// </summary>
        /// <param name="layoutSetupViewModel">The layout setup view model.</param>
        /// <param name="o">The o.</param>
        /// <param name="arg3">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
        private static void Columns_CollectionChanged(LayoutSetupViewModel layoutSetupViewModel, object o, NotifyCollectionChangedEventArgs arg3)
        {
            if (!layoutSetupViewModel._loadingColumns)
            {
                if (layoutSetupViewModel.Parent != null)
                {
                    layoutSetupViewModel.Parent.NotifyLayoutChanged();
                }

                layoutSetupViewModel.ReSortAvailableFields();
            }
        }
コード例 #4
0
        /// <summary>
        /// Available fields collection changed.
        /// </summary>
        /// <param name="layoutSetupViewModel">The layout setup view model.</param>
        /// <param name="o">The o.</param>
        /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
        private static void AvailableFields_CollectionChanged(LayoutSetupViewModel layoutSetupViewModel, object o, NotifyCollectionChangedEventArgs e)
        {
            if (!layoutSetupViewModel._loadingAvailableFields && e.Action == NotifyCollectionChangedAction.Add)
            {
                var index = 0;
                layoutSetupViewModel._loadingColumns = true;
                foreach (var columnViewModel in (ObservableCollection<GridColumnViewModel>)o)
                {
                    var column = layoutSetupViewModel.Columns.FirstOrDefault(c => c.SystemName == columnViewModel.SystemName);
                    if (column != null)
                    {
                        column.Index = index;
                        layoutSetupViewModel.Columns.Remove(column);
                        layoutSetupViewModel.Columns.Insert(index, column);
                        index++;
                    }
                }
                layoutSetupViewModel._loadingColumns = false;

                if (layoutSetupViewModel.Parent != null)
                    layoutSetupViewModel.Parent.NotifyLayoutChanged();
            }
        }
コード例 #5
0
 public void PropertiesTest()
 {
     var classUnderTest = new LayoutSetupViewModel();
     TestsHelper.TestPublicDeclaredPropertiesGetSet(classUnderTest, true);
 }