コード例 #1
0
        public void DataboundReactiveListDoesNotThrowForInsertRange()
        {
            var vm   = new LegacyPropertyBindViewModel();
            var view = new LegacyPropertyBindView
            {
                ViewModel = vm
            };
            var fixture = new PropertyBinderImplementation();

            fixture.OneWayBind(vm, view, m => m.SomeCollectionOfStrings, v => v.FakeItemsControl.ItemsSource);
            vm.SomeCollectionOfStrings.ResetChangeThreshold = int.MinValue;

            foreach (var item in Create(5))
            {
                vm.SomeCollectionOfStrings.Add(item);
            }

            // within reset threshold
            vm.SomeCollectionOfStrings.InsertRange(2, Create(5));

            // outside reset threshold
            vm.SomeCollectionOfStrings.InsertRange(2, Create(20));

            IEnumerable <string> Create(int numElements) => Enumerable.Range(1, numElements).Select(i => $"item_{i}");
        }
コード例 #2
0
        public void DataboundReactiveListDoesNotThrowForAddRange()
        {
            var vm   = new LegacyPropertyBindViewModel();
            var view = new LegacyPropertyBindView
            {
                ViewModel = vm
            };
            var fixture = new PropertyBinderImplementation();

            fixture.OneWayBind(vm, view, m => m.SomeCollectionOfStrings, v => v.FakeItemsControl.ItemsSource);

            // eliminate the ResetChangeThreshold from the equation
            vm.SomeCollectionOfStrings.ResetChangeThreshold = int.MinValue;

            // Within the reset threshold
            vm.SomeCollectionOfStrings.AddRange(Create(5));
            vm.SomeCollectionOfStrings.AddRange(Create(20));

            IEnumerable <string> Create(int numElements) => Enumerable.Range(1, numElements).Select(i => $"item_{i}");
        }