コード例 #1
0
        public void PublicPropertiesGetSetTest()
        {
            var behavior = new RadGridViewSelectionBehavior();

            var selectedItems = new ObservableCollection<object>();
            behavior.SelectedItems = selectedItems;
            Assert.AreEqual(behavior.SelectedItems, selectedItems);

            var updateSelectedItems = true;
            behavior.UpdateSelectedItems = updateSelectedItems;
            Assert.AreEqual(behavior.UpdateSelectedItems, updateSelectedItems);

            updateSelectedItems = false;
            behavior.UpdateSelectedItems = updateSelectedItems;
            Assert.AreEqual(behavior.UpdateSelectedItems, updateSelectedItems);
        }
コード例 #2
0
        public void SelectedItemsShouldNotChange_IfUpdateSelectedItemsIsFalse()
        {
            #region Arrange

            var item1 = new ItemStub { Id = 1 };
            var item2 = new ItemStub { Id = 2 };
            var item3 = new ItemStub { Id = 3 };

            var source = new ObservableCollection<object> { item1, item2, item3 };
            var selectedItems = new ObservableCollection<object>();

            var grid = new RadGridView { ItemsSource = source };
            var behavior = new RadGridViewSelectionBehavior() { UpdateSelectedItems = false, SelectedItems = selectedItems };
            behavior.Attach(grid);

            #endregion Arrange

            // Act
            grid.SelectedItems.Add(item1);

            // Assert
            const int Expected = 0;
            Assert.AreEqual(Expected, behavior.SelectedItems.Count);
        }
コード例 #3
0
        public void AssociatedObjectOnDataLoadedTest()
        {
            #region Arrange

            var item1 = new ItemStub { Id = 1 };
            var item2 = new ItemStub { Id = 2 };
            var item3 = new ItemStub { Id = 3 };
            var expectedItem = item2;

            var source = new ObservableCollection<object> { item1, item2, item3 };
            var selectedItems = new ObservableCollection<object> { expectedItem };

            var grid = new RadGridView();
            var behavior = new RadGridViewSelectionBehavior() { UpdateSelectedItems = true, SelectedItems = selectedItems };
            behavior.Attach(grid);

            #endregion Arrange

            // Act
            grid.ItemsSource = source;

            // Assert
            const int ExpectedCount = 1;
            Assert.AreEqual(ExpectedCount, grid.SelectedItems.Count);
            Assert.AreEqual(expectedItem, grid.SelectedItems.FirstOrDefault());
        }