コード例 #1
0
		public void MatchesWithASunnyDayAttributeTypeAndInheritance()
		{
			AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
			cut.Attribute = typeof(MarkupAttribute);
			bool matches = cut.Matches(typeof(InheritedWithMarkup).GetMethod("Bing"), null);
			Assert.IsTrue(matches, "Inherited method was decorated with the target attribute, so this must match.");
		}
コード例 #2
0
        public void MatchesWithAMethodThatDontMatchTheAttributeTypeAndNoInheritance()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute = typeof(MarkupAttribute);
            bool matches = cut.Matches(typeof(WithMarkup).GetMethod("RiloKiley"), null);

            Assert.IsFalse(matches, "Method was not decorated with the target attribute, so this must not match.");
        }
コード例 #3
0
        public void MatchesWithASunnyDayAttributeTypeAndInheritance()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute = typeof(MarkupAttribute);
            bool matches = cut.Matches(typeof(InheritedWithMarkup).GetMethod("Bing"), null);

            Assert.IsTrue(matches, "Inherited method was decorated with the target attribute, so this must match.");
        }
コード例 #4
0
        public void MatchesWithAnInterfaceMethodThatMatchesTheAttributeTypeAndNoCheckInterfaces()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute       = typeof(MarkupAttribute);
            cut.CheckInterfaces = false;
            bool matches = cut.Matches(typeof(ImplementingClass).GetMethod("OtherTestMethod"), null);

            Assert.IsFalse(matches, "Implementing method was not decorated with the target attribute, so this must not match since CheckInterfaces is false.");
        }
コード例 #5
0
        public void MatchesWithAnIndirectInterfaceMethodFromSubclassThatMatchesTheAttributeTypeAndCheckInterfaces()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute       = typeof(MarkupAttribute);
            cut.CheckInterfaces = true;
            bool matches = cut.Matches(typeof(InheritedImplementingClass).GetMethod("TestMethod", new Type[] { }), null);

            Assert.IsTrue(matches, "Implementing method from subclass was not decorated with the target attribute " +
                          "but the method from an indirectly implemented interface was, so this must match.");
        }
コード例 #6
0
        public void MatchesWithAnOverloadedInterfaceMethod()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute       = typeof(MarkupAttribute);
            cut.CheckInterfaces = true;
            bool matches = cut.Matches(typeof(ImplementingClass).GetMethod("TestMethod", new Type[] { typeof(string) }), null);

            Assert.IsFalse(matches, "Overloaded method from an implemented interface is not decorated with" +
                           " the attribute, so should not match.");
        }
コード例 #7
0
        public void MatchesWithAnInterfaceMethodThatMatchesTheAttributeTypeAndCheckInterfaces()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute       = typeof(MarkupAttribute);
            cut.CheckInterfaces = true;
            bool matches = cut.Matches(typeof(ImplementingClass).GetMethod("OtherTestMethod"), null);

            Assert.IsTrue(matches, "Implementing method was not decorated with the target attribute, " +
                          "but the method from the interface was, so this must match.");
        }
コード例 #8
0
        public void MatchesWhenExplicitlyImplemed()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute       = typeof(MarkupAttribute);
            cut.CheckInterfaces = true;

            // Only methods implemented expicitly are marked with attribute
            foreach (MethodInfo mi in typeof(ExplicitlyImplementingClass).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic))
            {
                if (mi.Name.IndexOf('.') == -1)
                {
                    continue;
                }
                bool matches = cut.Matches(mi, null);
                Assert.IsTrue(matches, "Explicitly implemented method must match");
            }
        }
コード例 #9
0
        public void AttributeSetterWithNonAttributeType()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute = GetType();
        }
コード例 #10
0
 public void MatchesWithAnInterfaceMethodThatMatchesTheAttributeTypeAndNoCheckInterfaces()
 {
     AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
     cut.Attribute = typeof(MarkupAttribute);
     cut.CheckInterfaces = false;
     bool matches = cut.Matches(typeof(ImplementingClass).GetMethod("OtherTestMethod"), null);
     Assert.IsFalse(matches, "Implementing method was not decorated with the target attribute, so this must not match since CheckInterfaces is false.");
 }
コード例 #11
0
        public void AttributeSetterWithNullType()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute = null;             // must allow this (no Exception)...
        }
コード例 #12
0
		public void AttributeSetterWithNullType()
		{
			AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
			cut.Attribute = null; // must allow this (no Exception)...
		}
コード例 #13
0
		public void AttributeSetterWithASunnyDayAttributeType()
		{
			AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
			cut.Attribute = typeof(SerializableAttribute); // must allow this too (no Exception)...
		}
コード例 #14
0
		public void AttributeSetterWithNonAttributeType()
		{
			AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
			cut.Attribute = GetType();
		}
コード例 #15
0
        public void MatchesWhenExplicitlyImplemed()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
            cut.Attribute = typeof(MarkupAttribute);
            cut.CheckInterfaces = true;

            // Only methods implemented expicitly are marked with attribute
            foreach (MethodInfo mi in typeof(ExplicitlyImplementingClass).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)) 
            {
                if (mi.Name.IndexOf('.') == -1) continue;
                bool matches = cut.Matches(mi, null);
                Assert.IsTrue(matches, "Explicitly implemented method must match");
            }

        }
コード例 #16
0
 public void MatchesWithAnIndirectInterfaceMethodFromSubclassThatMatchesTheAttributeTypeAndCheckInterfaces()
 {
     AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
     cut.Attribute = typeof(MarkupAttribute);
     cut.CheckInterfaces = true;
     bool matches = cut.Matches(typeof(InheritedImplementingClass).GetMethod("TestMethod", new Type[] { }), null);
     Assert.IsTrue(matches, "Implementing method from subclass was not decorated with the target attribute " +
         "but the method from an indirectly implemented interface was, so this must match.");
 }
コード例 #17
0
 public void MatchesWithAnOverloadedInterfaceMethod()
 {
     AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
     cut.Attribute = typeof(MarkupAttribute);
     cut.CheckInterfaces = true;
     bool matches = cut.Matches(typeof(ImplementingClass).GetMethod("TestMethod", new Type[] { typeof(string) }), null);
     Assert.IsFalse(matches, "Overloaded method from an implemented interface is not decorated with" +
         " the attribute, so should not match.");
 }
コード例 #18
0
 public void MatchesWithAnInterfaceMethodThatMatchesTheAttributeTypeAndCheckInterfaces()
 {
     AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
     cut.Attribute = typeof(MarkupAttribute);
     cut.CheckInterfaces = true;
     bool matches = cut.Matches(typeof(ImplementingClass).GetMethod("OtherTestMethod"), null);
     Assert.IsTrue(matches, "Implementing method was not decorated with the target attribute, " + 
         "but the method from the interface was, so this must match.");
 }
コード例 #19
0
        public void AttributeSetterWithASunnyDayAttributeType()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            cut.Attribute = typeof(SerializableAttribute);             // must allow this too (no Exception)...
        }
コード例 #20
0
		public void MatchesWithAMethodThatDontMatchTheAttributeTypeAndNoInheritance()
		{
			AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
			cut.Attribute = typeof(MarkupAttribute);
			bool matches = cut.Matches(typeof(WithMarkup).GetMethod("RiloKiley"), null);
			Assert.IsFalse(matches, "Method was not decorated with the target attribute, so this must not match.");
		}
コード例 #21
0
        public void AttributeSetterWithNonAttributeType()
        {
            AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();

            Assert.Throws <ArgumentException>(() => cut.Attribute = GetType());
        }
コード例 #22
0
		public void AttributeSetterWithNonAttributeType()
		{
			AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
            Assert.Throws<ArgumentException>(() => cut.Attribute = GetType());
		}