public void AddInterceptorsTests_AddMultipleInterceptorRefsToSingleMethodInSingleContractTest() { RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception; configSource.AddInterceptorRef(UnitOfWorkContract, CommitMethod, typeof(Apworks.Tests.Common.Interceptors.ExceptionHandlingInterceptor).AssemblyQualifiedName); configSource.AddInterceptorRef(UnitOfWorkContract, CommitMethod, typeof(Apworks.Tests.Common.Interceptors.LoggingInterceptor).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>(2, 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); Assert.AreEqual <string>(typeof(Apworks.Tests.Common.Interceptors.LoggingInterceptor).AssemblyQualifiedName, configSource.Config.Interception.Contracts.GetItemAt(0).Methods.GetItemAt(0).InterceptorRefs.GetItemAt(1).Name); }
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); }
/// <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) { var name = this.interceptorType.FullName; container.AddInterceptor(name, this.interceptorType); container.AddInterceptorRef(this.contractType, this.interceptMethod, name); return container; }