private static void Execute(
            IncludeAttribute sut,
            MethodInfo method,
            List <IFilter> filters,
            List <RegexRule> regexRules,
            Mock <IRegexFilter> regexFilterMock,
            Mock <IArgumentNullExceptionFixture> fixtureMock,
            int additionalRules)
        {
            // Arrange
            sut.ExclusionType = ExclusionType.Types;
            regexFilterMock.SetupGet(r => r.Rules).Returns(regexRules);
            filters.Add(regexFilterMock.Object);
            fixtureMock.SetupGet(f => f.Filters).Returns(filters);
            List <RegexRule> existingRules = regexRules.ToList();

            // Act
            IArgNullExCustomization customization = sut.GetCustomization(method);

            customization.Customize(fixtureMock.Object);

            // Assert
            Assert.Equal(existingRules.Count + additionalRules, regexRules.Count);
            Assert.False(existingRules.Except(regexRules).Any());
        }
        public void ThrowIfBothTypeAndTypeFullNameSpecified(
            IncludeAttribute sut,
            MethodInfo method,
            Mock <IArgumentNullExceptionFixture> fixtureMock)
        {
            // AAA
            IArgNullExCustomization customization = sut.GetCustomization(method);

            Assert.Throws <InvalidOperationException>(() => customization.Customize(fixtureMock.Object));
        }
        /// <summary>
        /// Applies the <paramref name="customization"/>.
        /// </summary>
        /// <param name="fixture">The fixture.</param>
        /// <param name="customization">The customization to apply.</param>
        /// <returns>The <paramref name="fixture"/>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="fixture"/> or <paramref name="customization"/>
        /// parameters are <see langword="null"/>.</exception>
        public static IArgumentNullExceptionFixture Customize(this IArgumentNullExceptionFixture fixture, IArgNullExCustomization customization)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException(nameof(fixture));
            }
            if (customization == null)
            {
                throw new ArgumentNullException(nameof(customization));
            }

            customization.Customize(fixture);
            return(fixture);
        }
        public void ExcludeNone(
            ExcludeAllAttribute sut,
            MethodInfo method)
        {
            // Arrange
            sut.ExclusionType = ExclusionType.None;
            var fixture = new ArgumentNullExceptionFixture(GetType().GetTypeInfo().Assembly);
            IArgNullExCustomization customization = sut.GetCustomization(method);

            // Act
            customization.Customize(fixture);

            // Assert
            IRegexFilter regexFilter = fixture.Filters.OfType <IRegexFilter>().Single();

            Assert.Empty(regexFilter.Rules);
        }
        public void ExcludeAllMethods(
            ExcludeAllAttribute sut,
            MethodInfo method)
        {
            // Arrange
            sut.ExclusionType = ExclusionType.Methods;
            var fixture = new ArgumentNullExceptionFixture(GetType().GetTypeInfo().Assembly);
            IArgNullExCustomization customization = sut.GetCustomization(method);

            // Act
            customization.Customize(fixture);
            IEnumerable <MethodData> data = fixture.GetData();

            // Assert
            Assert.Empty(data);
            IRegexFilter regexFilter = fixture.Filters.OfType <IRegexFilter>().Single();

            Assert.Single(regexFilter.Rules);
            AssertSingleExcludeAllMethodsRule(regexFilter);
        }
        public void ThrowIfNothingSpecified(
            IncludeAttribute sut,
            MethodInfo method,
            List <IFilter> filters,
            List <RegexRule> regexRules,
            Mock <IRegexFilter> regexFilterMock,
            Mock <IArgumentNullExceptionFixture> fixtureMock)
        {
            // Arrange
            regexFilterMock.SetupGet(r => r.Rules).Returns(regexRules);
            filters.Add(regexFilterMock.Object);
            fixtureMock.SetupGet(f => f.Filters).Returns(filters);

            // Act
            sut.Parameter    = null;
            sut.Method       = null;
            sut.Type         = null;
            sut.TypeFullName = null;
            IArgNullExCustomization customization = sut.GetCustomization(method);

            Assert.Throws <InvalidOperationException>(() => customization.Customize(fixtureMock.Object));
        }
        /// <summary>
        /// Applies the <paramref name="customization"/>.
        /// </summary>
        /// <param name="fixture">The fixture.</param>
        /// <param name="customization">The customization to apply.</param>
        /// <returns>The <paramref name="fixture"/>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="fixture"/> or <paramref name="customization"/>
        /// parameters are <see langword="null"/>.</exception>
        public static IArgumentNullExceptionFixture Customize(this IArgumentNullExceptionFixture fixture, IArgNullExCustomization customization)
        {
            if (fixture == null)
                throw new ArgumentNullException("fixture");
            if (customization == null)
                throw new ArgumentNullException("customization");

            customization.Customize(fixture);
            return fixture;
        }