Пример #1
0
        public void AddRange_EventMustBeFired()
        {
            var coll = new SilentObservableCollection <int>();
            NotifyCollectionChangedEventArgs arg = null;

            coll.CollectionChanged += (_, e) => arg = e;
            coll.AddRange(1, 2, 3, 45);
            Assert.IsNotNull(arg);
        }
Пример #2
0
        public void AddRange_AllValueMustAdded()
        {
            var set = new HashSet <int>
            {
                1, 2, 3, 4, 5, 67, 8, 91, 9, 87, 6, 5342, 2, 56, 43, 47
            };
            var coll = new SilentObservableCollection <int>();

            coll.AddRange(set);
            Assert.AreEqual(set.Count, coll.Count);
            var inSetCount = coll.Distinct().Where(x => set.Contains(x)).Count();

            Assert.AreEqual(set.Count, inSetCount);
        }
Пример #3
0
        public UnoTtileService()
        {
            var tbx = new TextBlock
            {
                MaxWidth     = 280,
                TextTrimming = TextTrimming.WordEllipsis
            };

            TitleControl = tbx;
            tbx.SetBinding(TextBlock.TextProperty, new Binding {
                Path = new PropertyPath(nameof(Title)), Source = this
            });
            tbx.SetBinding(ToolTipService.ToolTipProperty, new Binding
            {
                Path   = new PropertyPath(nameof(Title)),
                Source = this
            });
            LeftControls = new SilentObservableCollection <FrameworkElement>();
        }
Пример #4
0
        public TitleService()
        {
            var tbx = new TextBlock
            {
                MaxWidth     = 280,
                TextTrimming = TextTrimming.WordEllipsis
            };

            TitleControl = tbx;
            tbx.Bind(TextBlock.TextProperty, new Binding(nameof(Title))
            {
                Source = this
            });
            tbx.Bind(ToolTip.TipProperty, new Binding(nameof(Title))
            {
                Source = this
            });
            LeftControls = new SilentObservableCollection <IControl>();
        }
Пример #5
0
        public void InitWithData_CollectionMustContains()
        {
            var dt   = new int[] { 1, 2, 3 };
            var coll = new SilentObservableCollection <int>(dt);

            Check();
            var lst = new List <int> {
                1, 2, 3
            };

            coll = new SilentObservableCollection <int>(lst);
            Check();
            void Check()
            {
                Assert.AreEqual(3, coll.Count);
                Assert.AreEqual(1, coll[0]);
                Assert.AreEqual(2, coll[1]);
                Assert.AreEqual(3, coll[2]);
            }
        }