예제 #1
0
        public void FullDefinitionMatch()
        {
            var matcher = MemberMatcher.Create("MyPropPrivate");

            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivate))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropProtected))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivateStatic))).Should().BeFalse();
        }
예제 #2
0
        public void StaticOnlyConstructorMatching()
        {
            var matcher = MemberMatcher.Create("[static|constructor]*");

            matcher.IsMatch(GetConstructorDefinition(true)).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivate))).Should().BeFalse();
            matcher.IsMatch(GetStaticConstructorDefinition()).Should().BeTrue();
        }
예제 #3
0
        public void PartialDefinitionProtectedVisibility()
        {
            var matcher = MemberMatcher.Create("[protected]*Protected");

            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtected))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropProtected))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropInternal))).Should().BeFalse();
        }
예제 #4
0
        public void ConstructorMatchingWithVisibility()
        {
            var matcher = MemberMatcher.Create("[protected|constructor]*");

            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivate))).Should().BeFalse();
            matcher.IsMatch(GetConstructorDefinition(true)).Should().BeFalse();
            matcher.IsMatch(GetConstructorDefinition(false)).Should().BeTrue();
            matcher.IsMatch(GetStaticConstructorDefinition()).Should().BeTrue();
        }
예제 #5
0
        public void PartialDefinitionIstancePrivate()
        {
            var matcher = MemberMatcher.Create("[instance|private]My*");

            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivate))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropProtected))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropInternal))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodPrivate))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtected))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivateStatic))).Should().BeFalse();
        }
예제 #6
0
        public void SortTest_LongerNameFirstIfBothContainsStar()
        {
            var matcher1 = MemberMatcher.Create("My*Class");
            var matcher2 = MemberMatcher.Create("*MyCl");
            var list     = new List <MemberMatcher> {
                matcher2, matcher1
            };

            list.Sort();
            list[0].Should().Be(matcher1);
            list[1].Should().Be(matcher2);
        }
예제 #7
0
        public void SortTest_LessQuestionMarksFirst()
        {
            var matcher1 = MemberMatcher.Create("MyClas?");
            var matcher2 = MemberMatcher.Create("MyCla??");
            var list     = new List <MemberMatcher> {
                matcher2, matcher1
            };

            list.Sort();
            list[0].Should().Be(matcher1);
            list[1].Should().Be(matcher2);
        }
예제 #8
0
        public void SortTest_ScopeDefsDoesntMatter()
        {
            var matcher1 = MemberMatcher.Create("MyClass");
            var matcher2 = MemberMatcher.Create("[public]MyCl");
            var list     = new List <MemberMatcher> {
                matcher2, matcher1
            };

            list.Sort();
            list[0].Should().Be(matcher1);
            list[1].Should().Be(matcher2);
        }
예제 #9
0
        public void SortTest_NameWithoutStarFirst()
        {
            var matcher1 = MemberMatcher.Create("MyClass");
            var matcher2 = MemberMatcher.Create("MyClassIsLongerButContains*");
            var list     = new List <MemberMatcher> {
                matcher2, matcher1
            };

            list.Sort();
            list[0].Should().Be(matcher1);
            list[1].Should().Be(matcher2);
        }
예제 #10
0
        public void PartialDefinitionAllVisibilityStatic()
        {
            var matcher = MemberMatcher.Create("My*");

            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivateStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropProtectedStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropInternalStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPublicStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodPrivateStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtectedStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodInternalStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtectedInternalStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodPublicStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(OtherPropPublicStatic))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(OtherMethodPublicStatic))).Should().BeFalse();
        }
예제 #11
0
        public void PartialDefinitionStaticSetters()
        {
            var matcher = MemberMatcher.Create("[static|set]My*");

            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivateStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropProtectedStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropInternalStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPublicStatic))).Should().BeTrue();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPrivate))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropProtected))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropInternal))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyPropPublic))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodPrivate))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtected))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodInternal))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtectedInternal))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodPublic))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodPrivateStatic))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtectedStatic))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodInternalStatic))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodProtectedInternalStatic))).Should().BeFalse();
            matcher.IsMatch(GetMethodDefinition(nameof(MyMethodPublicStatic))).Should().BeFalse();
        }
예제 #12
0
 public Maybe <RuntimeMember> FindMatchingMember(Type targetType, MemberMatcher matcher)
 {
     return(FindMatchingMember(targetType, BindingFlags.Public, matcher)
            .OrMaybe(() => FindMatchingMember(targetType, BindingFlags.NonPublic, matcher)));
 }
예제 #13
0
 Maybe <RuntimeMember> FindMatchingMember(Type targetType, BindingFlags accessFlag, MemberMatcher matcher)
 {
     return(matcher.Match(targetType.GetMembers(flags | accessFlag | BindingFlags.FlattenHierarchy)));
 }
예제 #14
0
 Maybe<RuntimeMember> FindMatchingMember(Type targetType, BindingFlags accessFlag, MemberMatcher matcher) {
     return matcher.Match(targetType.GetMembers(flags | accessFlag | BindingFlags.FlattenHierarchy));
 }
예제 #15
0
 public Maybe<RuntimeMember> FindMatchingMember(Type targetType, MemberMatcher matcher) {
     return FindMatchingMember(targetType, BindingFlags.Public, matcher)
             .OrMaybe(() => FindMatchingMember(targetType, BindingFlags.NonPublic, matcher));
 }
예제 #16
0
        public void PartialDefinitioGenericMethod()
        {
            var matcher = MemberMatcher.Create("My*");

            matcher.IsMatch(GetMethodDefinition(nameof(MyGeneric))).Should().BeTrue();
        }
예제 #17
0
        public void EmptyMemberNameFails()
        {
            Action action = () => MemberMatcher.Create("[]");

            action.Should().Throw <ArgumentException>();
        }