コード例 #1
0
        internal void ApplyParameterFilters(
            SpecimenProvider specimenProvider,
            RegexFilter filter)
        {
            // Arrange
            filter.IncludeMethod("Compare", typeof(Uri))
            .ExcludeParameter("uri1", typeof(Uri))
            .ExcludeParameter("uri2", typeof(Uri), "Compare")
            .Rules.Add(new RegexRule("exclude all", type: new Regex(".*"), method: new Regex(".*")));

            IArgumentNullExceptionFixture sut =
                new ArgumentNullExceptionFixture(typeof(Uri).GetTypeInfo().Assembly,
                                                 specimenProvider,
                                                 new List <IFilter> {
                filter
            },
                                                 new List <IMapping>());

            // Act
            List <MethodData> methodDatas = sut.GetData().ToList();

            // Assert
            Assert.Equal(3, methodDatas.Count);
            Assert.Equal(3, methodDatas.Select(m => m.ExecutionSetup).OfType <DefaultExecutionSetup>().Count());
        }
コード例 #2
0
        public void CreateErroredMethodInvocationData(
            Mock <ISpecimenProvider> specimenProviderMock,
            FileNotFoundException exception,
            RegexFilter filter)
        {
            // Arrange
            specimenProviderMock.Setup(sp => sp.GetParameterSpecimens(It.IsAny <IList <ParameterInfo> >(), It.IsAny <int>()))
            .Throws(exception);
            filter.IncludeMethod("Compare", typeof(Uri))
            .Rules.Add(new RegexRule("exclude all", type: new Regex(".*"), method: new Regex(".*")));

            IArgumentNullExceptionFixture sut =
                new ArgumentNullExceptionFixture(typeof(Uri).GetTypeInfo().Assembly,
                                                 specimenProviderMock.Object,
                                                 new List <IFilter> {
                filter
            },
                                                 new List <IMapping>());

            // Act
            List <MethodData> methodDatas = sut.GetData().ToList();

            // Assert
            Assert.Equal(5, methodDatas.Count);
            List <ErroredExecutionSetup> executionSetups = methodDatas.Select(m => m.ExecutionSetup).OfType <ErroredExecutionSetup>().ToList();

            Assert.Equal(5, executionSetups.Count);
            foreach (ErroredExecutionSetup executionSetup in executionSetups)
            {
                CompositionException compositionException = Assert.IsType <CompositionException>(executionSetup.Exception);
                Assert.Same(exception, compositionException.InnerException);
            }
        }
コード例 #3
0
        internal void CreateInstanceMethodInvocationData(
            SpecimenProvider specimenProvider,
            RegexFilter filter)
        {
            // Arrange
            filter.IncludeMethod("GetComponents", typeof(Uri))
            .Rules.Add(new RegexRule("exclude all", type: new Regex(".*"), method: new Regex(".*")));

            IArgumentNullExceptionFixture sut =
                new ArgumentNullExceptionFixture(typeof(Uri).GetTypeInfo().Assembly,
                                                 specimenProvider,
                                                 new List <IFilter> {
                filter
            },
                                                 new List <IMapping>());

            // Act
            List <MethodData> methodDatas = sut.GetData().ToList();

            // Assert
            Assert.Equal(2, methodDatas.Count);
            Assert.Equal(2, methodDatas.Select(m => m.ExecutionSetup).OfType <DefaultExecutionSetup>().Count());
        }