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); }
public void AddInterceptorsTests_AddMultipleInterceptorsWithSameTypeTest() { RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception; configSource.AddInterceptor("1", typeof(ExceptionHandlingInterceptor)); configSource.AddInterceptor("2", typeof(ExceptionHandlingInterceptor)); Assert.AreEqual <int>(1, configSource.Config.Interception.Interceptors.Count); }
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) { 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; }
public void AddInterceptorsTests_AddInvalidInterceptorTypeTest() { RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception; configSource.AddInterceptor("1", this.GetType()); }