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);
        }
Exemplo n.º 2
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.ObjectContainer    = this.Type;
     container.InitFromConfigFile = this.initFromConfigFile;
     container.SectionName        = this.sectionName;
     return(container);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
 }
Exemplo n.º 9
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.Application = this.Type;
     return container;
 }
Exemplo n.º 10
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddResourceManager(this.resourceType, this.resourceName);

            return container;
        }
Exemplo n.º 11
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddMiscSetting(key, value);

            return(container);
        }
Exemplo n.º 12
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddMiscSetting(key, value);

            return container;
        }
Exemplo n.º 13
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.Logger = this.Type;
     return(container);
 }
Exemplo n.º 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());
        }
Exemplo n.º 16
0
 protected override RegularConfigSource DoConfigure(RegularConfigSource container)
 {
     container.Logger = this.Type;
     return container;
 }
Exemplo n.º 17
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddAppPlugin(this.type, this.name);

            return(container);
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 21
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;
 }
Exemplo n.º 22
0
        protected override RegularConfigSource DoConfigure(RegularConfigSource container)
        {
            container.AddAppPlugin(this.type, this.name);

            return container;
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }