public void GetAttributes_Throws_IfMultipleAttributesPresentAndAllowMultipleIsFalse()
        {
            Func <Attribute, bool> filter     = attribute => attribute.GetType() == typeof(SampleAttribute);
            AttributeConvention    convention = new TestAttributeConvention(filter, false);

            ExceptionAssert.ThrowsArgument(
                () => convention.GetAttributes(GetType().GetMethod("GetAttributes_Throws_IfMultipleAttributesPresentAndAllowMultipleIsFalse")),
                "member",
                "The member 'GetAttributes_Throws_IfMultipleAttributesPresentAndAllowMultipleIsFalse' on type 'AttributeConventionTests' contains multiple instances of the attribute 'SampleAttribute'.");
        }
        public void GetAttributes_Throws_IfMultipleAttributesPresentAndAllowMultipleIsFalse()
        {
            Func<Attribute, bool> filter = attribute => attribute.GetType() == typeof(SampleAttribute);
            AttributeConvention convention = new TestAttributeConvention(filter, false);

            Assert.ThrowsArgument(
                () => convention.GetAttributes(GetType().GetMethod("GetAttributes_Throws_IfMultipleAttributesPresentAndAllowMultipleIsFalse")),
                "member",
                "The member 'GetAttributes_Throws_IfMultipleAttributesPresentAndAllowMultipleIsFalse' on type 'AttributeConventionTests' contains multiple instances of the attribute 'SampleAttribute'.");
        }
        public void GetAttributes_InvokesFilter()
        {
            // Arrange
            int filterInvoked             = 0;
            Func <Attribute, bool> filter = attribute =>
            {
                filterInvoked++;
                return(true);
            };

            AttributeConvention convention = new TestAttributeConvention(filter, true);

            // Act & Assert
            Assert.Equal(
                new[] { "FactAttribute" },
                convention.GetAttributes(GetType().GetMethod("GetAttributes_InvokesFilter")).Select(a => a.GetType().Name));
            Assert.Equal(1, filterInvoked);
        }
        public void GetAttributes_InvokesFilter()
        {
            // Arrange
            int filterInvoked = 0;
            Func<Attribute, bool> filter = attribute =>
            {
                filterInvoked++;
                return true;
            };

            AttributeConvention convention = new TestAttributeConvention(filter, true);

            // Act & Assert
            Assert.Equal(
                new[] { "FactAttribute" },
                convention.GetAttributes(GetType().GetMethod("GetAttributes_InvokesFilter")).Select(a => a.GetType().Name));
            Assert.Equal(1, filterInvoked);
        }