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); }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.ObjectContainer = this.Type; container.InitFromConfigFile = this.initFromConfigFile; container.SectionName = this.sectionName; return(container); }
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); }
/// <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)); }
/// <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); }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.Application = this.Type; return container; }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.AddResourceManager(this.resourceType, this.resourceName); return container; }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.AddMiscSetting(key, value); return(container); }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.AddMiscSetting(key, value); return container; }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.Logger = this.Type; 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); }
public void AddInterceptorsTests_AddInvalidInterceptorTypeTest() { RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception; configSource.AddInterceptor("1", this.GetType()); }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.Logger = this.Type; return container; }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.AddAppPlugin(this.type, this.name); 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) { var name = this.interceptorType.FullName; container.AddInterceptor(name, this.interceptorType); container.AddInterceptorRef(this.contractType, this.interceptMethod, name); 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.IdentityGenerator = Type; 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.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; }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.AddAppPlugin(this.type, this.name); return container; }
/// <summary> /// 配置容器. /// </summary> /// <param name="container">配置容器.</param> /// <returns>已配置的容器.</returns> protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.AddHandler(name, handlerKind, 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.Application = Type; return(container); }
protected override RegularConfigSource DoConfigure(RegularConfigSource container) { container.AddResourceManager(this.resourceType, this.resourceName); return(container); }