public void IgnoreOption_Test()
        {
            var Configure    = new AspectConfigure();
            var ignoreOption = Configure.GetConfigureOption <bool>();

            Assert.NotNull(ignoreOption);
            Assert.NotEmpty(ignoreOption);
        }
Пример #2
0
        public void Configure_ValidateInterceptor_Test()
        {
            var configure = new AspectConfigure();

            configure.GetConfigureOption <IInterceptor>().Add(m => new IncrementAttribute());
            var validator = AspectValidatorFactory.GetAspectValidator(configure);

            Assert.True(validator.Validate(ReflectionExtensions.GetMethod <Action <ConfigureInterceptorValidatorModel> >(m => m.Validate())));
        }
Пример #3
0
        public void ValidateIgnoredList_Test()
        {
            var configure = new AspectConfigure();

            configure.GetConfigureOption <bool>().Add(m => m.DeclaringType.Name.Matches("IgnoredList*"));
            var validator = AspectValidatorFactory.GetAspectValidator(configure);

            Assert.False(validator.Validate(ReflectionExtensions.GetMethod <Action <IgnoredListValidatorModel> >(m => m.Validate())));
            Assert.False(validator.Validate(ReflectionExtensions.GetMethod <Action <object> >(m => m.ToString())));
        }
        public void UseOption_Test()
        {
            var Configure  = new AspectConfigure();
            var userOption = Configure.GetConfigureOption <IInterceptor>();

            Assert.NotNull(userOption);
            Assert.Empty(userOption);
            Func <MethodInfo, IInterceptor> defaultOption = m => default(IInterceptor);

            userOption.Add(defaultOption);
            Assert.Contains(defaultOption, userOption);
        }
Пример #5
0
        public void With_Configure_Interceptor_Test()
        {
            var Configure = new AspectConfigure();

            var ConfigureInterceptor = new InjectedInterceptor();

            Configure.GetConfigureOption <IInterceptor>().Add(m => ConfigureInterceptor);

            var matcher = new InterceptorMatcher(Configure);
            var method  = ReflectionExtensions.GetMethod <Action <InterceptorMatcherModel> >(m => m.ConfigureInterceptor());

            var interceptors = matcher.Match(method, method.DeclaringType.GetTypeInfo());

            Assert.NotEmpty(interceptors);

            Assert.Single(interceptors, ConfigureInterceptor);
        }