public void Invoke_MemberWithParameters_ThrowsTargetParameterCountException()
        {
            var list = new SubDesignerActionList();
            var item = new DesignerActionMethodItem(list, nameof(SubDesignerActionList.MethodWithParameters), "displayName", "category", "description");

            Assert.Throws <TargetParameterCountException>(() => item.Invoke());
        }
        public void Invoke_NoSuchMemberName_ThrowsInvalidOperationException(string memberName)
        {
            var list = new SubDesignerActionList();
            var item = new DesignerActionMethodItem(list, memberName, "displayName", "category", "description");

            Assert.Throws <InvalidOperationException>(() => item.Invoke());
        }
        public void Invoke_NullMemberName_ThrowsArgumentNullException()
        {
            var list = new SubDesignerActionList();
            var item = new DesignerActionMethodItem(list, null, "displayName", "category", "description");

            Assert.Throws <ArgumentNullException>("name", () => item.Invoke());
        }
        public void Invoke_ValidMemberName_ReturnsExpected(string memberName)
        {
            var list = new SubDesignerActionList();
            var item = new DesignerActionMethodItem(list, memberName, "displayName", "category", "description");

            item.Invoke();
            Assert.Equal(memberName, list.CalledMethod);

            // Call again to test caching behaviour.
            list.CalledMethod = null;
            item.Invoke();
            Assert.Equal(memberName, list.CalledMethod);
        }
        public void DesignerActionList_GetSortedActionItems_CustomClass_ReturnsExpected()
        {
            var list = new SubDesignerActionList();
            DesignerActionItemCollection items = list.GetSortedActionItems();

            Assert.Equal(8, items.Count);

            DesignerActionMethodItem item1 = Assert.IsType <DesignerActionMethodItem>(items[0]);

            Assert.Equal("AnnotatedMethod", item1.MemberName);
            Assert.Equal("DisplayName", item1.DisplayName);
            Assert.Equal("Description", item1.Description);
            Assert.Equal("Category", item1.Category);

            DesignerActionPropertyItem item2 = Assert.IsType <DesignerActionPropertyItem>(items[1]);

            Assert.Equal("AnnotatedProperty", item2.MemberName);
            Assert.Equal("DisplayName", item2.DisplayName);
            Assert.Equal("Description", item2.Description);
            Assert.Equal("Category", item2.Category);

            DesignerActionMethodItem item3 = Assert.IsType <DesignerActionMethodItem>(items[2]);

            Assert.Equal("EmptyAnnotatedMethod", item3.MemberName);
            Assert.Equal("EmptyAnnotatedMethod", item3.DisplayName);
            Assert.Empty(item3.Description);
            Assert.Empty(item3.Category);

            DesignerActionPropertyItem item4 = Assert.IsType <DesignerActionPropertyItem>(items[3]);

            Assert.Equal("EmptyAnnotatedProperty", item4.MemberName);
            Assert.Equal("EmptyAnnotatedProperty", item4.DisplayName);
            Assert.Empty(item4.Description);
            Assert.Empty(item4.Category);

            DesignerActionMethodItem item5 = Assert.IsType <DesignerActionMethodItem>(items[4]);

            Assert.Equal("NullAnnotatedMethod", item5.MemberName);
            Assert.Equal("NullAnnotatedMethod", item5.DisplayName);
            Assert.Null(item5.Description);
            Assert.Null(item5.Category);

            DesignerActionPropertyItem item6 = Assert.IsType <DesignerActionPropertyItem>(items[5]);

            Assert.Equal("NullAnnotatedProperty", item6.MemberName);
            Assert.Equal("NullAnnotatedProperty", item6.DisplayName);
            Assert.Null(item6.Description);
            Assert.Null(item6.Category);

            DesignerActionMethodItem item7 = Assert.IsType <DesignerActionMethodItem>(items[6]);

            Assert.Equal("PublicMethod", item7.MemberName);
            Assert.Equal("PublicMethod", item7.DisplayName);
            Assert.Empty(item7.Description);
            Assert.Empty(item7.Category);

            DesignerActionPropertyItem item8 = Assert.IsType <DesignerActionPropertyItem>(items[7]);

            Assert.Equal("PublicProperty", item8.MemberName);
            Assert.Equal("PublicProperty", item8.DisplayName);
            Assert.Empty(item8.Description);
            Assert.Empty(item8.Category);
        }