public void InitializeInterceptorsTests_MockSingleInterceptorTest()
        {
            Helper.ClearApp(AppRuntime.Instance);
            bool a = false;
            bool b = false;

            MockInterceptorA.InterceptOccur += (s, e) =>
            {
                a = true;
            };
            MockInterceptorB.InterceptOccur += (s, e) =>
            {
                b = true;
            };

            RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception;

            configSource.AddInterceptor("a", typeof(MockInterceptorA));
            configSource.AddInterceptor("b", typeof(MockInterceptorB));
            configSource.AddInterceptorRef(typeof(MessageDispatcher), typeof(MessageDispatcher).GetMethod("Clear", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance), "a");
            IApp app = AppRuntime.Create(configSource);

            app.Initialize += (s, e) =>
            {
                UnityContainer c = e.ObjectContainer.GetWrappedContainer <UnityContainer>();
                c.RegisterType <IMessageDispatcher, MessageDispatcher>();
            };
            app.Start();
            IMessageDispatcher dispatcher = app.ObjectContainer.GetService <IMessageDispatcher>();

            dispatcher.Clear();
            Assert.IsTrue(a);
            Assert.IsFalse(b);
        }
Пример #2
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.ObjectContainer    = this.Type;
     container.InitFromConfigFile = this.initFromConfigFile;
     container.SectionName        = this.sectionName;
     return(container);
 }
Пример #3
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.ObjectContainer = this.Type;
     container.InitFromConfigFile = this.initFromConfigFile;
     container.SectionName = this.sectionName;
     return container;
 }
        public void AddInterceptorsTests_AddSingleInterceptorTest()
        {
            RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception;

            configSource.AddInterceptor("1", typeof(ExceptionHandlingInterceptor));
            Assert.AreEqual <int>(1, configSource.Config.Interception.Interceptors.Count);
        }
Пример #5
0
        /// <summary>
        /// Configures the container.
        /// </summary>
        /// <param name="container">The configuration container.</param>
        /// <returns>The configured container.</returns>
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            var name = this.interceptorType.FullName;

            container.AddInterceptor(name, this.interceptorType);
            container.AddInterceptorRef(this.contractType, this.interceptMethod, name);
            return(container);
        }
        public void AddInterceptorsTests_AddSingleInterceptorRefToSingleMethodInSingleContractTest()
        {
            RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception;

            configSource.AddInterceptorRef(UnitOfWorkContract, CommitMethod, typeof(Apworks.Tests.Common.Interceptors.ExceptionHandlingInterceptor).AssemblyQualifiedName);
            Assert.IsNotNull(configSource.Config.Interception);
            Assert.AreEqual <int>(1, configSource.Config.Interception.Contracts.Count);
            Assert.AreEqual <string>(UnitOfWorkContract.AssemblyQualifiedName, configSource.Config.Interception.Contracts.GetItemAt(0).Type);
            Assert.AreEqual <int>(1, configSource.Config.Interception.Contracts.GetItemAt(0).Methods.Count);
            Assert.AreEqual <string>(CommitMethod.GetSignature(), configSource.Config.Interception.Contracts.GetItemAt(0).Methods.GetItemAt(0).Signature);
            Assert.AreEqual <int>(1, configSource.Config.Interception.Contracts.GetItemAt(0).Methods.GetItemAt(0).InterceptorRefs.Count);
            Assert.AreEqual <string>(typeof(Apworks.Tests.Common.Interceptors.ExceptionHandlingInterceptor).AssemblyQualifiedName, configSource.Config.Interception.Contracts.GetItemAt(0).Methods.GetItemAt(0).InterceptorRefs.GetItemAt(0).Name);
        }
        public void InitializeInterceptorsTests_InitAppTest()
        {
            RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception;

            configSource.AddInterceptor("exception", typeof(ExceptionHandlingInterceptor));
            configSource.AddInterceptor("logging", typeof(LoggingInterceptor));
            IApp app = AppRuntime.Create(configSource);

            Assert.IsNotNull(app.Interceptors);
            Assert.AreEqual <int>(2, app.Interceptors.Count());
            Assert.IsInstanceOfType(app.Interceptors.First(), typeof(ExceptionHandlingInterceptor));
            Assert.IsInstanceOfType(app.Interceptors.Last(), typeof(LoggingInterceptor));
        }
Пример #8
0
 /// <summary>
 /// Configures the container.
 /// </summary>
 /// <param name="container">The configuration container.</param>
 /// <returns>The configured container.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.SequenceGenerator = Type;
     return(container);
 }
Пример #9
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.Application = this.Type;
     return container;
 }
Пример #10
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddResourceManager(this.resourceType, this.resourceName);

            return container;
        }
Пример #11
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddMiscSetting(key, value);

            return(container);
        }
Пример #12
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddMiscSetting(key, value);

            return container;
        }
Пример #13
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.Logger = this.Type;
     return(container);
 }
Пример #14
0
 /// <summary>
 /// Configures the container.
 /// </summary>
 /// <param name="container">The configuration container.</param>
 /// <returns>The configured container.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.AddException(this.exceptionType, behavior);
     container.AddExceptionHandler(this.exceptionType, this.exceptionHandlerType);
     return(container);
 }
        public void AddInterceptorsTests_AddInvalidInterceptorTypeTest()
        {
            RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception;

            configSource.AddInterceptor("1", this.GetType());
        }
Пример #16
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.Logger = this.Type;
     return container;
 }
Пример #17
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddAppPlugin(this.type, this.name);

            return(container);
        }
Пример #18
0
 /// <summary>
 /// Configures the container.
 /// </summary>
 /// <param name="container">The configuration container.</param>
 /// <returns>The configured container.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     var name = this.interceptorType.FullName;
     container.AddInterceptor(name, this.interceptorType);
     container.AddInterceptorRef(this.contractType, this.interceptMethod, name);
     return container;
 }
Пример #19
0
 /// <summary>
 /// Configures the container.
 /// </summary>
 /// <param name="container">The configuration container.</param>
 /// <returns>The configured container.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.IdentityGenerator = Type;
     return container;
 }
Пример #20
0
 /// <summary>
 /// Configures the container.
 /// </summary>
 /// <param name="container">The configuration container.</param>
 /// <returns>The configured container.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.AddHandler(this.name, this.handlerKind, this.sourceType, this.source);
     return container;
 }
 /// <summary>
 /// Configures the container.
 /// </summary>
 /// <param name="container">The configuration container.</param>
 /// <returns>The configured container.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.AddException(this.exceptionType, behavior);
     container.AddExceptionHandler(this.exceptionType, this.exceptionHandlerType);
     return container;
 }
Пример #22
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddAppPlugin(this.type, this.name);

            return container;
        }
Пример #23
0
 /// <summary>
 /// 配置容器.
 /// </summary>
 /// <param name="container">配置容器.</param>
 /// <returns>已配置的容器.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.AddHandler(name, handlerKind, sourceType, this.source);
     return(container);
 }
Пример #24
0
 /// <summary>
 /// Configures the container.
 /// </summary>
 /// <param name="container">The configuration container.</param>
 /// <returns>The configured container.</returns>
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.Application = Type;
     return(container);
 }
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddResourceManager(this.resourceType, this.resourceName);

            return(container);
        }