Ejemplo n.º 1
0
        public virtual void CustomizeLinker(LinkerDriver linker, LinkerCustomizations customizations)
        {
            if (_testCaseTypeDefinition.CustomAttributes.Any(attr =>
                                                             attr.AttributeType.Name == nameof(DependencyRecordedAttribute)))
            {
                customizations.DependencyRecorder = new TestDependencyRecorder();
                customizations.CustomizeContext  += context => {
                    context.Tracer.AddRecorder(customizations.DependencyRecorder);
                };
            }

            if (ValidatesReflectionAccessPatterns(_testCaseTypeDefinition))
            {
                customizations.ReflectionPatternRecorder = new TestReflectionPatternRecorder();
                customizations.CustomizeContext         += context => {
                    customizations.ReflectionPatternRecorder.PreviousRecorder = context.ReflectionPatternRecorder;
                    context.ReflectionPatternRecorder = customizations.ReflectionPatternRecorder;
                    context.LogMessages = true;
                };
            }

            if (ValidatesLogMessages(_testCaseTypeDefinition))
            {
                customizations.CustomizeContext += context => {
                    context.LogMessages = true;
                };
            }
        }
Ejemplo n.º 2
0
        protected virtual LinkerCustomizations CustomizeLinker(LinkerDriver linker, TestCaseMetadataProvider metadataProvider)
        {
            LinkerCustomizations customizations = new LinkerCustomizations();

            metadataProvider.CustomizeLinker(linker, customizations);

            return(customizations);
        }
Ejemplo n.º 3
0
        public virtual void CustomizeLinker(LinkerDriver linker, LinkerCustomizations customizations)
        {
            if (_testCaseTypeDefinition.CustomAttributes.Any(attr =>
                                                             attr.AttributeType.Name == nameof(DependencyRecordedAttribute)))
            {
                customizations.DependencyRecorder = new TestDependencyRecorder();
                customizations.CustomizeContext  += context => {
                    context.Tracer.AddRecorder(customizations.DependencyRecorder);
                };
            }

            if (_testCaseTypeDefinition.CustomAttributes.Any(attr =>
                                                             attr.AttributeType.Name == nameof(VerifyAllReflectionAccessPatternsAreValidatedAttribute)) ||
                _testCaseTypeDefinition.AllMethods().Any(method => method.CustomAttributes.Any(attr =>
                                                                                               attr.AttributeType.Name == nameof(RecognizedReflectionAccessPatternAttribute) ||
                                                                                               attr.AttributeType.Name == nameof(UnrecognizedReflectionAccessPatternAttribute))))
            {
                customizations.ReflectionPatternRecorder = new TestReflectionPatternRecorder();
                customizations.CustomizeContext         += context => {
                    context.ReflectionPatternRecorder = customizations.ReflectionPatternRecorder;
                };
            }
            else if (_testCaseTypeDefinition.HasNestedTypes &&
                     _testCaseTypeDefinition.NestedTypes.Any(nestedType =>
                                                             nestedType.CustomAttributes.Any(attr =>
                                                                                             attr.AttributeType.Name == nameof(VerifyAllReflectionAccessPatternsAreValidatedAttribute) ||
                                                                                             nestedType.AllMethods().Any(method => method.CustomAttributes.Any(attr =>
                                                                                                                                                               attr.AttributeType.Name == nameof(RecognizedReflectionAccessPatternAttribute) ||
                                                                                                                                                               attr.AttributeType.Name == nameof(UnrecognizedReflectionAccessPatternAttribute))))))
            {
                customizations.ReflectionPatternRecorder = new TestReflectionPatternRecorder();
                customizations.CustomizeContext         += context => {
                    context.ReflectionPatternRecorder = customizations.ReflectionPatternRecorder;
                };
            }
        }