public void InternalAttributesAreIgnored()
        {
            var context    = ClassContextObjectMother.Create(typeof(ClassWithInternalAttribute));
            var definition = TargetClassDefinitionFactory.CreateAndValidate(context);

            Assert.That(definition.CustomAttributes.ContainsKey(typeof(InternalStuffAttribute)), Is.False);
        }
        public void CreateTargetClassDefinition_ReturnsValidClassDefinition()
        {
            var context = ClassContextObjectMother.Create(typeof(BaseType1));
            var def     = TargetClassDefinitionFactory.CreateAndValidate(context);

            Assert.That(def, Is.Not.Null);
            Assert.That(def.ConfigurationContext, Is.SameAs(context));
        }
        public TargetClassDefinition GetTargetClassDefinition(ClassContext classContext)
        {
            if (classContext == null)
            {
                return(null);
            }

            return(TargetClassDefinitionFactory.CreateAndValidate(classContext));
        }
Beispiel #4
0
        public static TargetClassDefinition GetActiveTargetClassDefinition(Type type)
        {
            ArgumentUtility.CheckNotNull("type", type);

            var classContext = MixinConfiguration.ActiveConfiguration.GetContext(type);

            Assert.That(classContext, Is.Not.Null, "The given type '" + type.Name + "' must be configured as a mixin target.");
            return(TargetClassDefinitionFactory.CreateAndValidate(classContext));
        }
Beispiel #5
0
        public void SetUp()
        {
            _remotionReflector = new Reflectors.Net4_5SupportReflector().Initialize(".");

            var mixinConfiguration = MixinConfiguration.BuildNew()
                                     .ForClass <TargetClass1> ()
                                     .AddMixin <Mixin1> ()
                                     .BuildConfiguration();

            _targetClassDefinition = TargetClassDefinitionFactory.CreateAndValidate(mixinConfiguration.ClassContexts.First());
            _mixinDefinition       = _targetClassDefinition.GetMixinByConfiguredType(typeof(Mixin1));
        }
Beispiel #6
0
        public void GetTargetClassDefinition()
        {
            var mixinConfiguration = MixinConfiguration.BuildNew()
                                     .ForClass <TargetClass1> ()
                                     .AddMixin <Mixin1> ()
                                     .BuildConfiguration();

            var reflectedOutput = _remotionReflector.GetTargetClassDefinition(typeof(TargetClass1), new ReflectedObject(mixinConfiguration), new ReflectedObject(mixinConfiguration.ClassContexts.GetWithInheritance(typeof(TargetClass1))));
            var expectedOutput  = TargetClassDefinitionFactory.CreateAndValidate(mixinConfiguration.ClassContexts.First());

            Assert.That(reflectedOutput.To <TargetClassDefinition> (), Is.InstanceOf(typeof(TargetClassDefinition)));
            Assert.That(reflectedOutput.To <TargetClassDefinition> ().FullName, Is.EqualTo(expectedOutput.FullName));
        }
        private static ConcreteMixinType GetGeneratedMixinTypeAndMetadata(ClassContext requestingClass, Type mixinType)
        {
            MixinDefinition mixinDefinition = TargetClassDefinitionFactory
                                              .CreateAndValidate(requestingClass)
                                              .GetMixinByConfiguredType(mixinType);

            Assert.That(mixinDefinition, Is.Not.Null);

            var mixinTypeIdentifier = mixinDefinition.GetConcreteMixinTypeIdentifier();

            var pipeline           = SafeServiceLocator.Current.GetInstance <IPipelineRegistry>().DefaultPipeline;
            var generatedMixinType = pipeline.ReflectionService.GetAdditionalType(mixinTypeIdentifier);

            return(new AttributeBasedMetadataImporter().GetMetadataForMixinType(generatedMixinType));
        }
Beispiel #8
0
        public void ReMotionApiUsages()
        {
            DeclarativeConfigurationBuilder.BuildConfigurationFromAssemblies(new Assembly[0]);
            TargetClassDefinitionFactory.CreateAndValidate(null);
            LogManager.GetLogger("");
            Use(new NonApplicationAssemblyAttribute());
            Use(new ConfigurationException(""));
            Use(new ValidationException(new ValidationLogData()));
            Use(typeof(IInitializableMixin));
            Use <TargetClassDefinition> (_ => _.GetMixinByConfiguredType(typeof(object)));
            Use <TargetClassDefinition> (_ => _.GetAllMembers());
            Use <TargetClassDefinition> (_ => _.ImplementedInterfaces);
            Use <TargetClassDefinition> (_ => _.ReceivedInterfaces);
            Use <ClassContext> (_ => _.ComposedInterfaces);
            Use <ClassContext> (_ => _.Mixins);
            Use <MixinDefinition> (_ => _.NextCallDependencies);
            Use <MixinDefinition> (_ => _.TargetCallDependencies);
            Use <MixinDefinition> (_ => _.GetAllOverrides());
            Use <MixinDefinition> (_ => _.AcceptsAlphabeticOrdering);
            Use <MixinDefinition> (_ => _.MixinIndex);
            Use <MixinDefinition> (_ => _.InterfaceIntroductions);
            Use <MixinDefinition> (_ => _.AttributeIntroductions);
            Use <MixinDefinition> (_ => _.TargetClass);
            Use <MixinContext> (_ => _.MixinType);
            Use <MixinContext> (_ => _.ExplicitDependencies);
            Use <MixinContext> (_ => _.MixinKind);
            Use <MixinConfiguration> (_ => _.ClassContexts);
            Use <ClassContextCollection> (_ => _.GetWithInheritance(typeof(object)));
            Use <ValidationException> (_ => _.Data); //TODO: add validationLogData from re-motion 1.15.6
            Use <AttributeIntroductionDefinition> (_ => _.AttributeType);
            Use <InterfaceIntroductionDefinition> (_ => _.InterfaceType);
            Use <MemberDefinitionBase> (_ => _.MemberType);
            Use <MemberDefinitionBase> (_ => _.Name);
            Use <MemberDefinitionBase> (_ => _.MemberInfo);
            Use <MemberDefinitionBase> (_ => _.BaseAsMember);
            Use <MemberDefinitionBase> (_ => _.Overrides);
            Use <MemberDefinitionBase> (_ => _.DeclaringClass);
            Use <ClassDefinitionBase> (_ => _.Type);
            Use <TargetCallDependencyDefinition> (_ => _.RequiredType);
            Use <RequiredTargetCallTypeDefinition> (_ => _.Type);

            //TODO: add SerializableValidationLogData members
        }
        public void CreateTargetClassDefinition_ValidatesWhenGeneratingDefinition()
        {
            var cc = ClassContextObjectMother.Create(typeof(DateTime));

            TargetClassDefinitionFactory.CreateAndValidate(cc);
        }
Beispiel #10
0
        public static TargetClassDefinition GetTargetClassDefinition(ClassContext classContext)
        {
            ArgumentUtility.CheckNotNull("classContext", classContext);

            return(TargetClassDefinitionFactory.CreateAndValidate(classContext));
        }