Esempio n. 1
0
        public void AddValueChanged()
        {
            MockPropertyDescriptor pd = new MockPropertyDescriptor(
                "Name", new Attribute [0]);
            object       compA    = new object();
            object       compB    = new object();
            EventHandler handlerA = new EventHandler(ValueChanged1);
            EventHandler handlerB = new EventHandler(ValueChanged1);
            EventHandler handlerC = new EventHandler(ValueChanged2);

            pd.AddValueChanged(compA, handlerA);
            pd.AddValueChanged(compA, handlerC);
            pd.AddValueChanged(compA, handlerC);
            pd.AddValueChanged(compA, handlerB);

            pd.FireValueChanged(compA, new EventArgs());
            Assert.AreEqual(4, _invokedHandlers.Count, "#A1");
            Assert.AreEqual("ValueChanged1", _invokedHandlers [0], "#A1");
            Assert.AreEqual("ValueChanged2", _invokedHandlers [1], "#A2");
            Assert.AreEqual("ValueChanged2", _invokedHandlers [2], "#A3");
            Assert.AreEqual("ValueChanged1", _invokedHandlers [3], "#A4");

            Reset();

            pd.FireValueChanged(compB, new EventArgs());
            Assert.AreEqual(0, _invokedHandlers.Count, "#B");
        }
Esempio n. 2
0
        public void Find()
        {
            PropertyDescriptor descA = new MockPropertyDescriptor("hehe_\u0061\u030a", 2);
            PropertyDescriptor descB = new MockPropertyDescriptor("heh_\u00e5", 3);
            PropertyDescriptor descC = new MockPropertyDescriptor("Foo", 5);
            PropertyDescriptor descD = new MockPropertyDescriptor("FOo", 6);
            PropertyDescriptor descE = new MockPropertyDescriptor("Aim", 1);
            PropertyDescriptor descF = new MockPropertyDescriptor("Bar", 4);

            PropertyDescriptorCollection col = new PropertyDescriptorCollection(
                new PropertyDescriptor [] { descA, descB, descC, descD, descE, descF });

            Assert.IsNull(col.Find("heh_\u0061\u030a", false), "#1");
            Assert.IsNull(col.Find("hehe_\u00e5", false), "#2");
            Assert.AreSame(descA, col.Find("hehe_\u0061\u030a", false), "#3");
            Assert.AreSame(descB, col.Find("heh_\u00e5", false), "#4");
            Assert.IsNull(col.Find("foo", false), "#5");
            Assert.AreSame(descC, col.Find("foo", true), "#6");
            Assert.AreSame(descD, col.Find("FOo", false), "#7");
            Assert.AreSame(descC, col.Find("FOo", true), "#8");
            Assert.IsNull(col.Find("fOo", false), "#9");
            Assert.AreSame(descC, col.Find("fOo", true), "#10");
            Assert.IsNull(col.Find("AIm", false), "#11");
            Assert.AreSame(descE, col.Find("AIm", true), "#12");
            Assert.IsNull(col.Find("AiM", false), "#13");
            Assert.AreSame(descE, col.Find("AiM", true), "#14");
            Assert.AreSame(descE, col.Find("Aim", false), "#15");
            Assert.AreSame(descE, col.Find("Aim", true), "#16");
        }
		public void Find ()
		{
			PropertyDescriptor descA = new MockPropertyDescriptor ("hehe_\u0061\u030a", 2);
			PropertyDescriptor descB = new MockPropertyDescriptor ("heh_\u00e5", 3);
			PropertyDescriptor descC = new MockPropertyDescriptor ("Foo", 5);
			PropertyDescriptor descD = new MockPropertyDescriptor ("FOo", 6);
			PropertyDescriptor descE = new MockPropertyDescriptor ("Aim", 1);
			PropertyDescriptor descF = new MockPropertyDescriptor ("Bar", 4);

			PropertyDescriptorCollection col = new PropertyDescriptorCollection (
				new PropertyDescriptor [] { descA, descB, descC, descD, descE, descF });

			Assert.IsNull (col.Find ("heh_\u0061\u030a", false), "#1");
			Assert.IsNull (col.Find ("hehe_\u00e5", false), "#2");
			Assert.AreSame (descA, col.Find ("hehe_\u0061\u030a", false), "#3");
			Assert.AreSame (descB, col.Find ("heh_\u00e5", false), "#4");
			Assert.IsNull (col.Find ("foo", false), "#5");
			Assert.AreSame (descC, col.Find ("foo", true), "#6");
			Assert.AreSame (descD, col.Find ("FOo", false), "#7");
			Assert.AreSame (descC, col.Find ("FOo", true), "#8");
			Assert.IsNull (col.Find ("fOo", false), "#9");
			Assert.AreSame (descC, col.Find ("fOo", true), "#10");
			Assert.IsNull (col.Find ("AIm", false), "#11");
			Assert.AreSame (descE, col.Find ("AIm", true), "#12");
			Assert.IsNull (col.Find ("AiM", false), "#13");
			Assert.AreSame (descE, col.Find ("AiM", true), "#14");
			Assert.AreSame (descE, col.Find ("Aim", false), "#15");
			Assert.AreSame (descE, col.Find ("Aim", true), "#16");
		}
Esempio n. 4
0
        [Test] // Sort (IComparer)
        public void Sort3()
        {
            PropertyDescriptorCollection descriptors;
            PropertyDescriptorCollection sorted;

            PropertyDescriptor descA = new MockPropertyDescriptor("Foo", 2);
            PropertyDescriptor descB = new MockPropertyDescriptor("Aim", 3);
            PropertyDescriptor descC = new MockPropertyDescriptor("Bim", 1);
            PropertyDescriptor descD = new MockPropertyDescriptor("AIm", 5);
            PropertyDescriptor descE = new MockPropertyDescriptor("Boo", 4);
            PropertyDescriptor descF = new MockPropertyDescriptor("FOo", 6);

            PropertyDescriptor [] props = new PropertyDescriptor []
            {
                descA, descB, descC, descD, descE, descF
            };
            descriptors = new PropertyDescriptorCollection(props);

            Assert.AreSame(descA, descriptors [0], "#A1");
            Assert.AreSame(descB, descriptors [1], "#A2");
            Assert.AreSame(descC, descriptors [2], "#A3");
            Assert.AreSame(descD, descriptors [3], "#A4");
            Assert.AreSame(descE, descriptors [4], "#A5");
            Assert.AreSame(descF, descriptors [5], "#A6");

            sorted = descriptors.Sort(new ComparableComparer());

            Assert.AreSame(descA, descriptors [0], "#B1");
            Assert.AreSame(descB, descriptors [1], "#B2");
            Assert.AreSame(descC, descriptors [2], "#B3");
            Assert.AreSame(descD, descriptors [3], "#B4");
            Assert.AreSame(descE, descriptors [4], "#B5");
            Assert.AreSame(descF, descriptors [5], "#B6");

            Assert.AreSame(descC, sorted [0], "#C1");
            Assert.AreSame(descA, sorted [1], "#C2");
            Assert.AreSame(descB, sorted [2], "#C3");
            Assert.AreSame(descE, sorted [3], "#C4");
            Assert.AreSame(descD, sorted [4], "#C5");
            Assert.AreSame(descF, sorted [5], "#C6");

            sorted = descriptors.Sort((Comparer)null);

            Assert.AreSame(descA, descriptors [0], "#D1");
            Assert.AreSame(descB, descriptors [1], "#D2");
            Assert.AreSame(descC, descriptors [2], "#D3");
            Assert.AreSame(descD, descriptors [3], "#D4");
            Assert.AreSame(descE, descriptors [4], "#D5");
            Assert.AreSame(descF, descriptors [5], "#D6");

            Assert.AreSame(descB, sorted [0], "#E1");
            Assert.AreSame(descD, sorted [1], "#E2");
            Assert.AreSame(descC, sorted [2], "#E3");
            Assert.AreSame(descE, sorted [3], "#E4");
            Assert.AreSame(descA, sorted [4], "#E5");
            Assert.AreSame(descF, sorted [5], "#E6");
        }
Esempio n. 5
0
        public void CanResetValueDelegates()
        {
            MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
            MockTypeFilterProvider filterProvider     = new MockTypeFilterProvider();

            TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

            descriptor.CanResetValue(null);
            Assert.IsTrue(propertyDescriptor.canResetValueInvoked, "ResetValue not delegated");
        }
        public void Ctor_Owner_Member()
        {
            var owner = new object();
            MemberDescriptor member = new MockPropertyDescriptor();
            var memberRelationship  = new MemberRelationship(owner, member);

            Assert.Same(owner, memberRelationship.Owner);
            Assert.Same(member, memberRelationship.Member);
            Assert.False(memberRelationship.IsEmpty);
        }
		public void CanResetValueDelegates()
		{
			MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
			MockTypeFilterProvider filterProvider = new MockTypeFilterProvider();

			TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

			descriptor.CanResetValue(null);
			Assert.IsTrue(propertyDescriptor.canResetValueInvoked, "ResetValue not delegated");
		}
		public void ComponentTypeDelegates()
		{
			MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
			MockTypeFilterProvider filterProvider = new MockTypeFilterProvider();

			TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

			Type type = descriptor.ComponentType;

			Assert.IsTrue(propertyDescriptor.getComponentTypeInvoked, "ComponentType not delegated");
		}
		public void FilterDescriptionDelegates()
		{
			MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
			MockTypeFilterProvider filterProvider = new MockTypeFilterProvider();

			TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

			string description = descriptor.FilterDescription;

			Assert.IsTrue(filterProvider.FilterDescriptionInvoked, "FilterDescription not invoked");
		}
Esempio n. 10
0
        public void ComponentTypeDelegates()
        {
            MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
            MockTypeFilterProvider filterProvider     = new MockTypeFilterProvider();

            TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

            Type type = descriptor.ComponentType;

            Assert.IsTrue(propertyDescriptor.getComponentTypeInvoked, "ComponentType not delegated");
        }
Esempio n. 11
0
        public void IsReadOnlyDelegated()
        {
            MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
            MockTypeFilterProvider filterProvider     = new MockTypeFilterProvider();

            TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

            bool isReadOnly = descriptor.IsReadOnly;

            Assert.IsTrue(propertyDescriptor.isReadOnlyInvoked, "IsReadOnly not delegated");
        }
Esempio n. 12
0
        public void ShouldSerializeValueDelegated()
        {
            MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
            MockTypeFilterProvider filterProvider     = new MockTypeFilterProvider();

            TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

            descriptor.ShouldSerializeValue(null);

            Assert.IsTrue(propertyDescriptor.shouldSerializeValueInvoked, "ShouldSerializeValue not delegated");
        }
Esempio n. 13
0
        public void FilterDescriptionDelegates()
        {
            MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
            MockTypeFilterProvider filterProvider     = new MockTypeFilterProvider();

            TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

            string description = descriptor.FilterDescription;

            Assert.IsTrue(filterProvider.FilterDescriptionInvoked, "FilterDescription not invoked");
        }
Esempio n. 14
0
        public void CanFilterDelegates()
        {
            MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
            MockTypeFilterProvider filterProvider     = new MockTypeFilterProvider();

            TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

            bool canFilter = descriptor.CanFilterType(typeof(System.String), true);

            Assert.IsTrue(filterProvider.CanFilterTypeInvoked, "CanFilterType not invoked");
        }
		public void CanFilterDelegates()
		{
			MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
			MockTypeFilterProvider filterProvider = new MockTypeFilterProvider();

			TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

			bool canFilter = descriptor.CanFilterType(typeof(System.String), true);

			Assert.IsTrue(filterProvider.CanFilterTypeInvoked, "CanFilterType not invoked");
		}
Esempio n. 16
0
        public void GetInvocationTarget_Type_Null()
        {
            MockPropertyDescriptor pd = new MockPropertyDescriptor(
                "Name", new Attribute [0]);

            try {
                pd.GetInvocationTarget((Type)null, new object());
                Assert.Fail("#1");
            } catch (ArgumentNullException ex) {
                Assert.AreEqual(typeof(ArgumentNullException), ex.GetType(), "#2");
                Assert.IsNull(ex.InnerException, "#3");
                Assert.IsNotNull(ex.Message, "#4");
                Assert.IsNotNull(ex.ParamName, "#5");
                Assert.AreEqual("type", ex.ParamName, "#6");
            }
        }
Esempio n. 17
0
        public void RemoveValueChanged_Component_Null()
        {
            MockPropertyDescriptor pd = new MockPropertyDescriptor(
                "Name", new Attribute [0]);

            try {
                pd.RemoveValueChanged(null, new EventHandler(ValueChanged1));
                Assert.Fail("#1");
            } catch (ArgumentNullException ex) {
                Assert.AreEqual(typeof(ArgumentNullException), ex.GetType(), "#2");
                Assert.IsNull(ex.InnerException, "#3");
                Assert.IsNotNull(ex.Message, "#4");
                Assert.IsNotNull(ex.ParamName, "#5");
                Assert.AreEqual("component", ex.ParamName, "#6");
            }
        }
Esempio n. 18
0
        public void AddValueChanged_Handler_Null()
        {
            MockPropertyDescriptor pd = new MockPropertyDescriptor(
                "Name", new Attribute [0]);

            try {
                pd.AddValueChanged(new object(), (EventHandler)null);
                Assert.Fail("#1");
            } catch (ArgumentNullException ex) {
                Assert.AreEqual(typeof(ArgumentNullException), ex.GetType(), "#2");
                Assert.IsNull(ex.InnerException, "#3");
                Assert.IsNotNull(ex.Message, "#4");
                Assert.IsNotNull(ex.ParamName, "#5");
                Assert.AreEqual("handler", ex.ParamName, "#6");
            }
        }
Esempio n. 19
0
        [Test]         // this [String]
        public void Indexer2()
        {
            PropertyDescriptor descA = new MockPropertyDescriptor("hehe_\u0061\u030a", 2);
            PropertyDescriptor descB = new MockPropertyDescriptor("heh_\u00e5", 3);
            PropertyDescriptor descC = new MockPropertyDescriptor("Foo", 5);
            PropertyDescriptor descD = new MockPropertyDescriptor("FOo", 6);
            PropertyDescriptor descE = new MockPropertyDescriptor("Aim", 1);
            PropertyDescriptor descF = new MockPropertyDescriptor("Bar", 4);

            PropertyDescriptorCollection col = new PropertyDescriptorCollection(
                new PropertyDescriptor [] { descA, descB, descC, descD, descE, descF });

            Assert.IsNull(col ["heh_\u0061\u030a"], "#1");
            Assert.IsNull(col ["hehe_\u00e5"], "#2");
            Assert.AreSame(descA, col ["hehe_\u0061\u030a"], "#3");
            Assert.AreSame(descB, col ["heh_\u00e5"], "#4");
            Assert.IsNull(col ["foo"], "#5");
            Assert.AreSame(descD, col ["FOo"], "#6");
            Assert.IsNull(col ["fOo"], "#7");
            Assert.IsNull(col ["AIm"], "#8");
            Assert.IsNull(col ["AiM"], "#9");
            Assert.AreSame(descE, col ["Aim"], "#10");
        }
Esempio n. 20
0
        [Test]         // Sort (String [], IComparer)
        public void Sort4()
        {
            PropertyDescriptorCollection descriptors;
            PropertyDescriptorCollection sorted;

            PropertyDescriptor descA = new MockPropertyDescriptor("Foo", 2);
            PropertyDescriptor descB = new MockPropertyDescriptor("Aim", 3);
            PropertyDescriptor descC = new MockPropertyDescriptor("Bim", 1);
            PropertyDescriptor descD = new MockPropertyDescriptor("AIm", 5);
            PropertyDescriptor descE = new MockPropertyDescriptor("Boo", 4);
            PropertyDescriptor descF = new MockPropertyDescriptor("FOo", 6);

            PropertyDescriptor [] props = new PropertyDescriptor [] {
                descA, descB, descC, descD, descE, descF
            };
            descriptors = new PropertyDescriptorCollection(props);

            Assert.AreSame(descA, descriptors [0], "#A1");
            Assert.AreSame(descB, descriptors [1], "#A2");
            Assert.AreSame(descC, descriptors [2], "#A3");
            Assert.AreSame(descD, descriptors [3], "#A4");
            Assert.AreSame(descE, descriptors [4], "#A5");
            Assert.AreSame(descF, descriptors [5], "#A6");

            sorted = descriptors.Sort(new string [] { "B", "Foo", null, "A", "Boo" },
                                      new ComparableComparer());

            Assert.AreSame(descA, descriptors [0], "#B1");
            Assert.AreSame(descB, descriptors [1], "#B2");
            Assert.AreSame(descC, descriptors [2], "#B3");
            Assert.AreSame(descD, descriptors [3], "#B4");
            Assert.AreSame(descE, descriptors [4], "#B5");
            Assert.AreSame(descF, descriptors [5], "#B6");

            Assert.AreSame(descA, sorted [0], "#C1");
            Assert.AreSame(descE, sorted [1], "#C2");
            Assert.AreSame(descC, sorted [2], "#C3");
            Assert.AreSame(descB, sorted [3], "#C4");
            Assert.AreSame(descD, sorted [4], "#C5");
            Assert.AreSame(descF, sorted [5], "#C6");

            sorted = descriptors.Sort((string [])null, new ComparableComparer());

            Assert.AreSame(descA, descriptors [0], "#D1");
            Assert.AreSame(descB, descriptors [1], "#D2");
            Assert.AreSame(descC, descriptors [2], "#D3");
            Assert.AreSame(descD, descriptors [3], "#D4");
            Assert.AreSame(descE, descriptors [4], "#D5");
            Assert.AreSame(descF, descriptors [5], "#D6");

            Assert.AreSame(descC, sorted [0], "#E1");
            Assert.AreSame(descA, sorted [1], "#E2");
            Assert.AreSame(descB, sorted [2], "#E3");
            Assert.AreSame(descE, sorted [3], "#E4");
            Assert.AreSame(descD, sorted [4], "#E5");
            Assert.AreSame(descF, sorted [5], "#E6");

            sorted = descriptors.Sort(new string [] { "B", "Foo", null, "A", "Boo" },
                                      (Comparer)null);

            Assert.AreSame(descA, descriptors [0], "#F1");
            Assert.AreSame(descB, descriptors [1], "#F2");
            Assert.AreSame(descC, descriptors [2], "#F3");
            Assert.AreSame(descD, descriptors [3], "#F4");
            Assert.AreSame(descE, descriptors [4], "#F5");
            Assert.AreSame(descF, descriptors [5], "#F6");

            Assert.AreSame(descA, sorted [0], "#G1");
            Assert.AreSame(descE, sorted [1], "#G2");
            Assert.AreSame(descB, sorted [2], "#G3");
            Assert.AreSame(descD, sorted [3], "#G4");
            Assert.AreSame(descC, sorted [4], "#G5");
            Assert.AreSame(descF, sorted [5], "#G6");

            sorted = descriptors.Sort((string [])null, (Comparer)null);

            Assert.AreSame(descA, descriptors [0], "#H1");
            Assert.AreSame(descB, descriptors [1], "#H2");
            Assert.AreSame(descC, descriptors [2], "#H3");
            Assert.AreSame(descD, descriptors [3], "#H4");
            Assert.AreSame(descE, descriptors [4], "#H5");
            Assert.AreSame(descF, descriptors [5], "#H6");

            Assert.AreSame(descB, sorted [0], "#I1");
            Assert.AreSame(descD, sorted [1], "#I2");
            Assert.AreSame(descC, sorted [2], "#I3");
            Assert.AreSame(descE, sorted [3], "#I4");
            Assert.AreSame(descA, sorted [4], "#I5");
            Assert.AreSame(descF, sorted [5], "#I6");
        }
Esempio n. 21
0
		public void RemoveValueChanged ()
		{
			MockPropertyDescriptor pd = new MockPropertyDescriptor (
				"Name", new Attribute [0]);
			object compA = new object ();
			object compB = new object ();
			EventHandler handlerA = new EventHandler (ValueChanged1);
			EventHandler handlerB = new EventHandler (ValueChanged1);
			EventHandler handlerC = new EventHandler (ValueChanged2);

			pd.AddValueChanged (compA, handlerA);
			pd.AddValueChanged (compA, handlerC);
			pd.AddValueChanged (compA, handlerC);
			pd.AddValueChanged (compA, handlerB);
			pd.AddValueChanged (compB, handlerC);

			pd.FireValueChanged (compA, new EventArgs ());
			Assert.AreEqual (4, _invokedHandlers.Count, "#A1");
			pd.RemoveValueChanged (new object (), handlerC);
			pd.FireValueChanged (compA, new EventArgs ());
			Assert.AreEqual (8, _invokedHandlers.Count, "#A2");

			Reset ();
			pd.RemoveValueChanged (compA, handlerC);

			pd.FireValueChanged (compA, new EventArgs ());
			Assert.AreEqual (3, _invokedHandlers.Count, "#B1");
			Assert.AreEqual ("ValueChanged1", _invokedHandlers [0], "#B2");
			Assert.AreEqual ("ValueChanged2", _invokedHandlers [1], "#B3");
			Assert.AreEqual ("ValueChanged1", _invokedHandlers [2], "#B4");

			Reset ();

			pd.FireValueChanged (compB, new EventArgs ());
			Assert.AreEqual (1, _invokedHandlers.Count, "#C1");
			Assert.AreEqual ("ValueChanged2", _invokedHandlers [0], "#C2");

			Reset ();
			pd.RemoveValueChanged (compB, handlerC);

			pd.FireValueChanged (compB, new EventArgs ());
			Assert.AreEqual (0, _invokedHandlers.Count, "#D");
		}
Esempio n. 22
0
		public void GetValueChangedHandler ()
		{
			object compA = new object ();
			object compB = new object ();
			EventHandler handlerA = new EventHandler (ValueChanged1);
			EventHandler handlerB = new EventHandler (ValueChanged1);
			EventHandler handlerC = new EventHandler (ValueChanged2);

			MockPropertyDescriptor pd = new MockPropertyDescriptor (
				"Name", new Attribute [0]);
			Assert.IsNull (pd.GetValueChangedHandler (null), "#A1");
			Assert.IsNull (pd.GetValueChangedHandler (compA), "#A2");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#A3");

			pd.AddValueChanged (compA, handlerA);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#B1");
			Assert.AreSame (handlerA, pd.GetValueChangedHandler (compA), "#B2");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#B3");

			pd.AddValueChanged (compA, handlerB);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#C1");
			EventHandler handler = pd.GetValueChangedHandler (compA);
			Assert.AreEqual (2, handler.GetInvocationList ().Length, "#C2");
			Assert.AreEqual (handlerA, handler.GetInvocationList () [0], "#C3");
			Assert.AreEqual (handlerB, handler.GetInvocationList () [1], "#C4");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#C5");

			pd.AddValueChanged (compB, handlerA);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#D1");
			handler = pd.GetValueChangedHandler (compA);
			Assert.AreEqual (2, handler.GetInvocationList ().Length, "#D2");
			Assert.AreSame (handlerA, pd.GetValueChangedHandler (compB), "#D3");

			pd.RemoveValueChanged (compB, handlerB);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#E1");
			handler = pd.GetValueChangedHandler (compA);
			Assert.AreEqual (2, handler.GetInvocationList ().Length, "#E2");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#E3");

			pd.RemoveValueChanged (compB, handlerB);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#F1");
			handler = pd.GetValueChangedHandler (compA);
			Assert.AreEqual (2, handler.GetInvocationList ().Length, "#F2");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#F3");

			pd.RemoveValueChanged (compA, handlerC);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#G1");
			handler = pd.GetValueChangedHandler (compA);
			Assert.AreEqual (2, handler.GetInvocationList ().Length, "#G2");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#G3");

			pd.AddValueChanged (compA, handlerC);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#H1");
			handler = pd.GetValueChangedHandler (compA);
			Assert.AreEqual (3, handler.GetInvocationList ().Length, "#H2");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#H3");

			pd.RemoveValueChanged (compA, handlerB);

			Assert.IsNull (pd.GetValueChangedHandler (null), "#I1");
			handler = pd.GetValueChangedHandler (compA);
			Assert.AreEqual (2, handler.GetInvocationList ().Length, "#I2");
			Assert.AreEqual (handlerA, handler.GetInvocationList () [0], "#I3");
			Assert.AreEqual (handlerC, handler.GetInvocationList () [1], "#I4");
			Assert.IsNull (pd.GetValueChangedHandler (compB), "#I5");
		}
Esempio n. 23
0
		public void GetInvocationTarget_Type_Null ()
		{
			MockPropertyDescriptor pd = new MockPropertyDescriptor (
				"Name", new Attribute [0]);
			try {
				pd.GetInvocationTarget ((Type) null, new object ());
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.IsNotNull (ex.ParamName, "#5");
				Assert.AreEqual ("type", ex.ParamName, "#6");
			}
		}
Esempio n. 24
0
		public void AddValueChanged_Handler_Null ()
		{
			MockPropertyDescriptor pd = new MockPropertyDescriptor (
				"Name", new Attribute [0]);
			try {
				pd.AddValueChanged (new object (), (EventHandler) null);
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.IsNotNull (ex.ParamName, "#5");
				Assert.AreEqual ("handler", ex.ParamName, "#6");
			}
		}
Esempio n. 25
0
		public void RemoveValueChanged_Component_Null ()
		{
			MockPropertyDescriptor pd = new MockPropertyDescriptor (
				"Name", new Attribute [0]);
			try {
				pd.RemoveValueChanged (null, new EventHandler (ValueChanged1));
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.IsNotNull (ex.ParamName, "#5");
				Assert.AreEqual ("component", ex.ParamName, "#6");
			}
		}
		[Test] // this [String]
		public void Indexer2 ()
		{
			PropertyDescriptor descA = new MockPropertyDescriptor ("hehe_\u0061\u030a", 2);
			PropertyDescriptor descB = new MockPropertyDescriptor ("heh_\u00e5", 3);
			PropertyDescriptor descC = new MockPropertyDescriptor ("Foo", 5);
			PropertyDescriptor descD = new MockPropertyDescriptor ("FOo", 6);
			PropertyDescriptor descE = new MockPropertyDescriptor ("Aim", 1);
			PropertyDescriptor descF = new MockPropertyDescriptor ("Bar", 4);

			PropertyDescriptorCollection col = new PropertyDescriptorCollection (
				new PropertyDescriptor [] { descA, descB, descC, descD, descE, descF });

			Assert.IsNull (col ["heh_\u0061\u030a"], "#1");
			Assert.IsNull (col ["hehe_\u00e5"], "#2");
			Assert.AreSame (descA, col ["hehe_\u0061\u030a"], "#3");
			Assert.AreSame (descB, col ["heh_\u00e5"], "#4");
			Assert.IsNull (col ["foo"], "#5");
			Assert.AreSame (descD, col ["FOo"], "#6");
			Assert.IsNull (col ["fOo"], "#7");
			Assert.IsNull (col ["AIm"], "#8");
			Assert.IsNull (col ["AiM"], "#9");
			Assert.AreSame (descE, col ["Aim"], "#10");
		}
Esempio n. 27
0
        private void AssertReadOnly(PropertyDescriptorCollection descriptors, string testCase)
        {
            MockPropertyDescriptor mockPropertyDescr = new MockPropertyDescriptor(
                "Date", DateTime.Now);

            try {
                descriptors.Add(mockPropertyDescr);
                Assert.Fail(testCase + "#1");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                descriptors.Add(null);
                Assert.Fail(testCase + "#2");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                descriptors.Clear();
                Assert.Fail(testCase + "#3");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                descriptors.Insert(0, mockPropertyDescr);
                Assert.Fail(testCase + "#4");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                descriptors.Insert(0, null);
                Assert.Fail(testCase + "#5");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                descriptors.Remove(mockPropertyDescr);
                Assert.Fail(testCase + "#6");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                descriptors.Remove(null);
                Assert.Fail(testCase + "#7");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                descriptors.RemoveAt(0);
                Assert.Fail(testCase + "#8");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            IList list = (IList)descriptors;

            Assert.IsTrue(((IList)descriptors).IsReadOnly, testCase + "#9");
            Assert.IsTrue(((IList)descriptors).IsFixedSize, testCase + "#10");

            try {
                list.Add(mockPropertyDescr);
                Assert.Fail(testCase + "#11");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                list.Add(null);
                Assert.Fail(testCase + "#12");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                list.Clear();
                Assert.Fail(testCase + "#13");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                list.Insert(0, mockPropertyDescr);
                Assert.Fail(testCase + "#14");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                list.Insert(0, null);
                Assert.Fail(testCase + "#15");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                list.Remove(mockPropertyDescr);
                Assert.Fail(testCase + "#16");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                list.Remove(null);
                Assert.Fail(testCase + "#17");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                list.RemoveAt(0);
                Assert.Fail(testCase + "#18");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                list[0] = mockPropertyDescr;
                Assert.Fail(testCase + "#19");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                list[0] = null;
                Assert.Fail(testCase + "#20");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            IDictionary dictionary = (IDictionary)descriptors;

            Assert.IsTrue(dictionary.IsReadOnly, testCase + "#21");
            Assert.IsTrue(dictionary.IsFixedSize, testCase + "#22");

            try {
                dictionary.Add("test", mockPropertyDescr);
                Assert.Fail(testCase + "#23");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // value is checked before read-only check
            try {
                dictionary.Add("test", null);
                Assert.Fail(testCase + "#24");
            } catch (ArgumentException) {
                // read-only collection cannot be modified
            }

            try {
                dictionary.Clear();
                Assert.Fail(testCase + "#25");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            try {
                dictionary[0] = mockPropertyDescr;
                Assert.Fail(testCase + "#26");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }

            // ensure read-only check if performed before value is checked
            try {
                dictionary[0] = null;
                Assert.Fail(testCase + "#27");
            } catch (NotSupportedException) {
                // read-only collection cannot be modified
            }
        }
		[Test] // Sort (String [], IComparer)
		public void Sort4 ()
		{
			PropertyDescriptorCollection descriptors;
			PropertyDescriptorCollection sorted;

			PropertyDescriptor descA = new MockPropertyDescriptor ("Foo", 2);
			PropertyDescriptor descB = new MockPropertyDescriptor ("Aim", 3);
			PropertyDescriptor descC = new MockPropertyDescriptor ("Bim", 1);
			PropertyDescriptor descD = new MockPropertyDescriptor ("AIm", 5);
			PropertyDescriptor descE = new MockPropertyDescriptor ("Boo", 4);
			PropertyDescriptor descF = new MockPropertyDescriptor ("FOo", 6);

			PropertyDescriptor [] props = new PropertyDescriptor [] {
				descA, descB, descC, descD, descE, descF };
			descriptors = new PropertyDescriptorCollection (props);

			Assert.AreSame (descA, descriptors [0], "#A1");
			Assert.AreSame (descB, descriptors [1], "#A2");
			Assert.AreSame (descC, descriptors [2], "#A3");
			Assert.AreSame (descD, descriptors [3], "#A4");
			Assert.AreSame (descE, descriptors [4], "#A5");
			Assert.AreSame (descF, descriptors [5], "#A6");

			sorted = descriptors.Sort (new string [] { "B", "Foo", null, "A", "Boo" },
				new ComparableComparer ());

			Assert.AreSame (descA, descriptors [0], "#B1");
			Assert.AreSame (descB, descriptors [1], "#B2");
			Assert.AreSame (descC, descriptors [2], "#B3");
			Assert.AreSame (descD, descriptors [3], "#B4");
			Assert.AreSame (descE, descriptors [4], "#B5");
			Assert.AreSame (descF, descriptors [5], "#B6");

			Assert.AreSame (descA, sorted [0], "#C1");
			Assert.AreSame (descE, sorted [1], "#C2");
			Assert.AreSame (descC, sorted [2], "#C3");
			Assert.AreSame (descB, sorted [3], "#C4");
			Assert.AreSame (descD, sorted [4], "#C5");
			Assert.AreSame (descF, sorted [5], "#C6");

			sorted = descriptors.Sort ((string []) null, new ComparableComparer ());

			Assert.AreSame (descA, descriptors [0], "#D1");
			Assert.AreSame (descB, descriptors [1], "#D2");
			Assert.AreSame (descC, descriptors [2], "#D3");
			Assert.AreSame (descD, descriptors [3], "#D4");
			Assert.AreSame (descE, descriptors [4], "#D5");
			Assert.AreSame (descF, descriptors [5], "#D6");

			Assert.AreSame (descC, sorted [0], "#E1");
			Assert.AreSame (descA, sorted [1], "#E2");
			Assert.AreSame (descB, sorted [2], "#E3");
			Assert.AreSame (descE, sorted [3], "#E4");
			Assert.AreSame (descD, sorted [4], "#E5");
			Assert.AreSame (descF, sorted [5], "#E6");

			sorted = descriptors.Sort (new string [] { "B", "Foo", null, "A", "Boo" },
				(Comparer) null);

			Assert.AreSame (descA, descriptors [0], "#F1");
			Assert.AreSame (descB, descriptors [1], "#F2");
			Assert.AreSame (descC, descriptors [2], "#F3");
			Assert.AreSame (descD, descriptors [3], "#F4");
			Assert.AreSame (descE, descriptors [4], "#F5");
			Assert.AreSame (descF, descriptors [5], "#F6");

			Assert.AreSame (descA, sorted [0], "#G1");
			Assert.AreSame (descE, sorted [1], "#G2");
			Assert.AreSame (descB, sorted [2], "#G3");
			Assert.AreSame (descD, sorted [3], "#G4");
			Assert.AreSame (descC, sorted [4], "#G5");
			Assert.AreSame (descF, sorted [5], "#G6");

			sorted = descriptors.Sort ((string []) null, (Comparer) null);

			Assert.AreSame (descA, descriptors [0], "#H1");
			Assert.AreSame (descB, descriptors [1], "#H2");
			Assert.AreSame (descC, descriptors [2], "#H3");
			Assert.AreSame (descD, descriptors [3], "#H4");
			Assert.AreSame (descE, descriptors [4], "#H5");
			Assert.AreSame (descF, descriptors [5], "#H6");

			Assert.AreSame (descB, sorted [0], "#I1");
			Assert.AreSame (descD, sorted [1], "#I2");
			Assert.AreSame (descC, sorted [2], "#I3");
			Assert.AreSame (descE, sorted [3], "#I4");
			Assert.AreSame (descA, sorted [4], "#I5");
			Assert.AreSame (descF, sorted [5], "#I6");
		}
		public void IsReadOnlyDelegated()
		{
			MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
			MockTypeFilterProvider filterProvider = new MockTypeFilterProvider();

			TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

			bool isReadOnly = descriptor.IsReadOnly;
			Assert.IsTrue(propertyDescriptor.isReadOnlyInvoked, "IsReadOnly not delegated");
		}
 public override void BeforeSetUpFixture()
 {
     mockTickPropertyDescriptor = new MockPropertyDescriptor("Tick", null, false);
     ComponentCreator.SetEventPropertyDescriptor(mockTickPropertyDescriptor);
 }
		[Test] // Sort (IComparer)
		public void Sort3 ()
		{
			PropertyDescriptorCollection descriptors;
			PropertyDescriptorCollection sorted;

			PropertyDescriptor descA = new MockPropertyDescriptor ("Foo", 2);
			PropertyDescriptor descB = new MockPropertyDescriptor ("Aim", 3);
			PropertyDescriptor descC = new MockPropertyDescriptor ("Bim", 1);
			PropertyDescriptor descD = new MockPropertyDescriptor ("AIm", 5);
			PropertyDescriptor descE = new MockPropertyDescriptor ("Boo", 4);
			PropertyDescriptor descF = new MockPropertyDescriptor ("FOo", 6);

			PropertyDescriptor [] props = new PropertyDescriptor [] {
				descA, descB, descC, descD, descE, descF };
			descriptors = new PropertyDescriptorCollection (props);

			Assert.AreSame (descA, descriptors [0], "#A1");
			Assert.AreSame (descB, descriptors [1], "#A2");
			Assert.AreSame (descC, descriptors [2], "#A3");
			Assert.AreSame (descD, descriptors [3], "#A4");
			Assert.AreSame (descE, descriptors [4], "#A5");
			Assert.AreSame (descF, descriptors [5], "#A6");

			sorted = descriptors.Sort (new ComparableComparer ());

			Assert.AreSame (descA, descriptors [0], "#B1");
			Assert.AreSame (descB, descriptors [1], "#B2");
			Assert.AreSame (descC, descriptors [2], "#B3");
			Assert.AreSame (descD, descriptors [3], "#B4");
			Assert.AreSame (descE, descriptors [4], "#B5");
			Assert.AreSame (descF, descriptors [5], "#B6");

			Assert.AreSame (descC, sorted [0], "#C1");
			Assert.AreSame (descA, sorted [1], "#C2");
			Assert.AreSame (descB, sorted [2], "#C3");
			Assert.AreSame (descE, sorted [3], "#C4");
			Assert.AreSame (descD, sorted [4], "#C5");
			Assert.AreSame (descF, sorted [5], "#C6");

			sorted = descriptors.Sort ((Comparer) null);

			Assert.AreSame (descA, descriptors [0], "#D1");
			Assert.AreSame (descB, descriptors [1], "#D2");
			Assert.AreSame (descC, descriptors [2], "#D3");
			Assert.AreSame (descD, descriptors [3], "#D4");
			Assert.AreSame (descE, descriptors [4], "#D5");
			Assert.AreSame (descF, descriptors [5], "#D6");

			Assert.AreSame (descB, sorted [0], "#E1");
			Assert.AreSame (descD, sorted [1], "#E2");
			Assert.AreSame (descC, sorted [2], "#E3");
			Assert.AreSame (descE, sorted [3], "#E4");
			Assert.AreSame (descA, sorted [4], "#E5");
			Assert.AreSame (descF, sorted [5], "#E6");
		}
		private void AssertReadOnly (PropertyDescriptorCollection descriptors, string testCase)
		{
			MockPropertyDescriptor mockPropertyDescr = new MockPropertyDescriptor (
				"Date", DateTime.Now);

			try {
				descriptors.Add (mockPropertyDescr);
				Assert.Fail (testCase + "#1");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				descriptors.Add (null);
				Assert.Fail (testCase + "#2");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				descriptors.Clear ();
				Assert.Fail (testCase + "#3");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				descriptors.Insert (0, mockPropertyDescr);
				Assert.Fail (testCase + "#4");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				descriptors.Insert (0, null);
				Assert.Fail (testCase + "#5");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				descriptors.Remove (mockPropertyDescr);
				Assert.Fail (testCase + "#6");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				descriptors.Remove (null);
				Assert.Fail (testCase + "#7");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				descriptors.RemoveAt (0);
				Assert.Fail (testCase + "#8");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			IList list = (IList) descriptors;
			Assert.IsTrue (((IList) descriptors).IsReadOnly, testCase + "#9");
			Assert.IsTrue (((IList) descriptors).IsFixedSize, testCase + "#10");

			try {
				list.Add (mockPropertyDescr);
				Assert.Fail (testCase + "#11");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				list.Add (null);
				Assert.Fail (testCase + "#12");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				list.Clear ();
				Assert.Fail (testCase + "#13");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				list.Insert (0, mockPropertyDescr);
				Assert.Fail (testCase + "#14");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				list.Insert (0, null);
				Assert.Fail (testCase + "#15");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				list.Remove (mockPropertyDescr);
				Assert.Fail (testCase + "#16");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				list.Remove (null);
				Assert.Fail (testCase + "#17");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				list.RemoveAt (0);
				Assert.Fail (testCase + "#18");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				list[0] = mockPropertyDescr;
				Assert.Fail (testCase + "#19");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				list[0] = null;
				Assert.Fail (testCase + "#20");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			IDictionary dictionary = (IDictionary) descriptors;
			Assert.IsTrue (dictionary.IsReadOnly, testCase + "#21");
			Assert.IsTrue (dictionary.IsFixedSize, testCase + "#22");

			try {
				dictionary.Add ("test", mockPropertyDescr);
				Assert.Fail (testCase + "#23");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// value is checked before read-only check
			try {
				dictionary.Add ("test", null);
				Assert.Fail (testCase + "#24");
			} catch (ArgumentException) {
				// read-only collection cannot be modified
			}

			try {
				dictionary.Clear ();
				Assert.Fail (testCase + "#25");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			try {
				dictionary[0] = mockPropertyDescr;
				Assert.Fail (testCase + "#26");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}

			// ensure read-only check if performed before value is checked
			try {
				dictionary[0] = null;
				Assert.Fail (testCase + "#27");
			} catch (NotSupportedException) {
				// read-only collection cannot be modified
			}
		}
Esempio n. 33
0
        public void GetValueChangedHandler()
        {
            object       compA    = new object();
            object       compB    = new object();
            EventHandler handlerA = new EventHandler(ValueChanged1);
            EventHandler handlerB = new EventHandler(ValueChanged1);
            EventHandler handlerC = new EventHandler(ValueChanged2);

            MockPropertyDescriptor pd = new MockPropertyDescriptor(
                "Name", new Attribute [0]);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#A1");
            Assert.IsNull(pd.GetValueChangedHandler(compA), "#A2");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#A3");

            pd.AddValueChanged(compA, handlerA);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#B1");
            Assert.AreSame(handlerA, pd.GetValueChangedHandler(compA), "#B2");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#B3");

            pd.AddValueChanged(compA, handlerB);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#C1");
            EventHandler handler = pd.GetValueChangedHandler(compA);

            Assert.AreEqual(2, handler.GetInvocationList().Length, "#C2");
            Assert.AreEqual(handlerA, handler.GetInvocationList() [0], "#C3");
            Assert.AreEqual(handlerB, handler.GetInvocationList() [1], "#C4");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#C5");

            pd.AddValueChanged(compB, handlerA);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#D1");
            handler = pd.GetValueChangedHandler(compA);
            Assert.AreEqual(2, handler.GetInvocationList().Length, "#D2");
            Assert.AreSame(handlerA, pd.GetValueChangedHandler(compB), "#D3");

            pd.RemoveValueChanged(compB, handlerB);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#E1");
            handler = pd.GetValueChangedHandler(compA);
            Assert.AreEqual(2, handler.GetInvocationList().Length, "#E2");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#E3");

            pd.RemoveValueChanged(compB, handlerB);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#F1");
            handler = pd.GetValueChangedHandler(compA);
            Assert.AreEqual(2, handler.GetInvocationList().Length, "#F2");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#F3");

            pd.RemoveValueChanged(compA, handlerC);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#G1");
            handler = pd.GetValueChangedHandler(compA);
            Assert.AreEqual(2, handler.GetInvocationList().Length, "#G2");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#G3");

            pd.AddValueChanged(compA, handlerC);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#H1");
            handler = pd.GetValueChangedHandler(compA);
            Assert.AreEqual(3, handler.GetInvocationList().Length, "#H2");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#H3");

            pd.RemoveValueChanged(compA, handlerB);

            Assert.IsNull(pd.GetValueChangedHandler(null), "#I1");
            handler = pd.GetValueChangedHandler(compA);
            Assert.AreEqual(2, handler.GetInvocationList().Length, "#I2");
            Assert.AreEqual(handlerA, handler.GetInvocationList() [0], "#I3");
            Assert.AreEqual(handlerC, handler.GetInvocationList() [1], "#I4");
            Assert.IsNull(pd.GetValueChangedHandler(compB), "#I5");
        }
		public void ShouldSerializeValueDelegated()
		{
			MockPropertyDescriptor propertyDescriptor = new MockPropertyDescriptor(testPropertyDescriptor);
			MockTypeFilterProvider filterProvider = new MockTypeFilterProvider();

			TypeFilterPropertyDescriptor descriptor = new TypeFilterPropertyDescriptor(propertyDescriptor, filterProvider);

			descriptor.ShouldSerializeValue(null);

			Assert.IsTrue(propertyDescriptor.shouldSerializeValueInvoked, "ShouldSerializeValue not delegated");
		}