/// <summary>
        /// Validates the whole configuration.
        /// </summary>
        /// <returns>An <see cref="ValidationLogData"/> object, which contains information about whether the configuration reresented by this context is valid.</returns>
        /// <remarks>This method retrieves definition items for all the <see cref="ClassContexts"/> known by this configuration and uses the
        /// <see cref="Validator"/> class to validate them. The validation results can be inspected, passed to a <see cref="ValidationException"/>, or
        /// be dumped using the <see cref="T:Remotion.Development.Mixins.Validation.ConsoleDumper"/>.</remarks>
        /// <exception cref="NotSupportedException">The <see cref="MixinConfiguration"/> contains a <see cref="ClassContext"/> for a generic type, of
        /// which it cannot make a closed generic type. Because closed types are needed for validation, this <see cref="MixinConfiguration"/>
        /// cannot be validated as a whole. Even in this case, the configuration might still be correct, but validation is deferred to
        /// <see cref="TargetClassDefinitionFactory.CreateAndValidate"/>.</exception>
        public ValidationLogData Validate()
        {
            var definitions = from classContext in ClassContexts
                              where !classContext.Type.IsGenericTypeDefinition && !classContext.Type.IsInterface
                              select(IVisitableDefinition) TargetClassDefinitionFactory.CreateWithoutValidation(classContext);

            return(Validator.Validate(definitions));
        }
示例#2
0
        public void FailsIfInterfaceMixinDependencyNotFulfilled()
        {
            ClassContext context = new ClassContextBuilder(typeof(TargetClassWithAdditionalDependencies)).AddMixin <MixinWithAdditionalInterfaceDependency> ().WithDependency <IMixinWithAdditionalClassDependency> ().BuildClassContext();

            TargetClassDefinition definition = TargetClassDefinitionFactory.CreateWithoutValidation(context);
            var log = Validator.Validate(definition.Mixins[typeof(MixinWithAdditionalInterfaceDependency)]);

            Assert.That(HasFailure("Remotion.Mixins.Validation.Rules.DefaultMixinDependencyRules.DependencyMustBeSatisfiedByAnotherMixin", log), Is.True);
        }
示例#3
0
        public static TargetClassDefinition BuildUnvalidatedDefinition(Type baseType, params Type[] mixinTypes)
        {
            ArgumentUtility.CheckNotNull("baseType", baseType);
            ArgumentUtility.CheckNotNull("mixinTypes", mixinTypes);

            var context = ClassContextObjectMother.Create(baseType, mixinTypes);

            return(TargetClassDefinitionFactory.CreateWithoutValidation(context));
        }