Beispiel #1
0
        public void Remove()
        {
            SetterBaseCollection sbc = new SetterBaseCollection();

            Assert.IsFalse(sbc.Remove(null), "null");
            Assert.IsFalse(sbc.Remove(new Setter()), "Empty");
        }
Beispiel #2
0
        public void SetterBaseCollection_Remove_When_Sealed()
        {
            var sbc    = new SetterBaseCollection();
            var setter = new Setter(Control.PaddingProperty, new Thickness(20d));

            sbc.Add(setter);

            sbc.Seal();

            sbc.IsSealed.Should().BeTrue();

            Assert.ThrowsException <InvalidOperationException>(() => sbc.Remove(setter));
        }
Beispiel #3
0
        public void SetterStillSealedAfterRemove()
        {
            Setter s = new Setter(UIElement.OpacityProperty, 2.0);
            SetterBaseCollection sbc = new SetterBaseCollection();

            Assert.IsFalse(sbc.IsSealed, "SetterBaseCollection.IsSealed-1");
            Assert.IsFalse(s.IsSealed, "Setter.IsSealed-1");
            sbc.Add(s);
            Assert.IsFalse(sbc.IsSealed, "SetterBaseCollection.IsSealed-2");
            Assert.IsTrue(s.IsSealed, "Setter.IsSealed-2");
            sbc.Remove(s);
            Assert.IsFalse(sbc.IsSealed, "SetterBaseCollection.IsSealed-3");
            Assert.IsTrue(s.IsSealed, "Setter.IsSealed-3");
        }
Beispiel #4
0
        public void Sealed()
        {
            Style style            = new Style(typeof(UIElement));
            SetterBaseCollection c = style.Setters;
            Setter s = new Setter(Canvas.LeftProperty, 0);

            c.Add(s);

            style.Seal();

            Assert.Throws(delegate { c.Add(new Setter(Canvas.TopProperty, 0)); }, typeof(Exception));
            Assert.Throws(delegate { c.Insert(0, new Setter(Canvas.TopProperty, 0)); }, typeof(Exception));

            /*Assert.Throws (delegate {*/ c.Remove(s);             /* }, typeof (Exception));*/

            Assert.AreEqual(0, c.Count);

            // need to reinitialize things here since the
            // Remove above actually succeeded.
            style = new Style(typeof(UIElement));
            c     = style.Setters;
            s     = new Setter(Canvas.LeftProperty, 0);

            c.Add(s);

            style.Seal();

            // lame, this should raise an exception too
            /*Assert.Throws (delegate {*/ c.RemoveAt(0);             /* }, typeof (Exception));*/

            Assert.AreEqual(0, c.Count);

            // need to reinitialize things here since the
            // RemoveAt above actually succeeded.
            style = new Style(typeof(UIElement));
            c     = style.Setters;
            s     = new Setter(Canvas.LeftProperty, 0);

            c.Add(s);

            style.Seal();

            Assert.Throws(delegate { c[0] = new Setter(Canvas.TopProperty, 0); }, typeof(Exception));
        }
Beispiel #5
0
        public void SetterBaseCollection_Remove_Null()
        {
            var sbc = new SetterBaseCollection();

            Assert.ThrowsException <ArgumentNullException>(() => sbc.Remove(null));
        }