public void CanEnumerateInterceptors() { // Arrange RequestInterceptorSet.Add("X", new SomeInterceptor()); RequestInterceptorSet.Add("Y", new SomeInterceptor()); IRequestInterceptor x = null; IRequestInterceptor y = null; // Act foreach (KeyValuePair <string, IRequestInterceptor> i in RequestInterceptorSet) { if (i.Key == "X") { x = i.Value; } else if (i.Key == "Y") { y = i.Value; } } // Assert Assert.IsNotNull(x); Assert.IsNotNull(y); }
/// <summary> /// The remove. /// </summary> /// <param name="interceptor"> /// The interceptor. /// </param> /// <exception cref="NotImplementedException"> /// </exception> public void Remove(IRequestInterceptor interceptor) { if (this._registeredInterceptors.Contains(interceptor)) { this._registeredInterceptors.Remove(interceptor); } }
/// <summary> /// Initializes a new instance of the <see cref="AutoUnregisterToken"/> class. /// </summary> /// <param name="factory"> The factory to unregister from. </param> /// <param name="interceptor"> The interceptor to remove on dispose. </param> public AutoUnregisterToken(IEasyPeasyFactory factory, IRequestInterceptor interceptor) { Ensure.IsNotNull(factory, "factory"); Ensure.IsNotNull(interceptor, "interceptor"); this.factory = factory; this.interceptor = interceptor; }
public void WhenNotFindingInterceptorItReturnsNull() { // Act IRequestInterceptor i = RequestInterceptorSet.Find("Y"); // Assert Assert.IsNull(i); }
/// <summary> /// Removes an interceptor from the factory /// </summary> /// <param name="interceptor">The interceptor to remove</param> public void RemoveInterceptor(IRequestInterceptor interceptor) { Ensure.IsNotNull(interceptor, "interceptor"); lock (Locker) { interceptors.Remove(interceptor); } }
public void CanAddAndGetInterceptor() { // Act RequestInterceptorSet.Add("X", new SomeInterceptor()); IRequestInterceptor i = RequestInterceptorSet.Find("X"); // Assert Assert.IsNotNull(i); }
/// <summary> /// Adds an interceptor to be notified when a request is sent and a response received /// </summary> /// <param name="interceptor">The interceptor to add</param> /// <returns>A token that automatically unregisters the interceptor when it is disposed</returns> public IDisposable AddInterceptor(IRequestInterceptor interceptor) { Ensure.IsNotNull(interceptor, "interceptor"); this.RemoveInterceptor(interceptor); lock (Locker) { interceptors.Add(interceptor); } return(new AutoUnregisterToken(this, interceptor)); }
/// <summary> /// The attach. /// </summary> /// <param name="interceptor"> /// The interceptor. /// </param> /// <exception cref="NotImplementedException"> /// </exception> public void Attach(IRequestInterceptor interceptor) { this._registeredInterceptors.Add(interceptor); }
public void Add(string name, IRequestInterceptor interceptor) { Interceptors.Add(name, interceptor); }
public void Add(IRequestInterceptor interceptor) { Add(interceptor.GetType().ToString(), interceptor); }
public void UnRegisterRequestInterceptor(IRequestInterceptor interceptor) { this.Dispatcher.Remove(interceptor); }
public void RegisterRequestInterceptor(IRequestInterceptor interceptor) { this.Dispatcher.Attach(interceptor); }
public void AddInterceptor(IRequestInterceptor requestInterceptor) { _requestInterceptors.Add(requestInterceptor); }