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);
        }
Exemple #2
0
 /// <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);
     }
 }
Exemple #3
0
        /// <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));
        }
Exemple #8
0
 /// <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);
 }
Exemple #10
0
 public void Add(IRequestInterceptor interceptor)
 {
   Add(interceptor.GetType().ToString(), interceptor);
 }
Exemple #11
0
 public void UnRegisterRequestInterceptor(IRequestInterceptor interceptor)
 {
     this.Dispatcher.Remove(interceptor);
 }
 public void Add(string name, IRequestInterceptor interceptor)
 {
     Interceptors.Add(name, interceptor);
 }
 public void Add(IRequestInterceptor interceptor)
 {
     Add(interceptor.GetType().ToString(), interceptor);
 }
Exemple #14
0
 /// <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);
     }
 }
Exemple #15
0
 public void RegisterRequestInterceptor(IRequestInterceptor interceptor)
 {
     this.Dispatcher.Attach(interceptor);
 }
Exemple #16
0
 public void AddInterceptor(IRequestInterceptor requestInterceptor)
 {
     _requestInterceptors.Add(requestInterceptor);
 }
Exemple #17
0
 /// <summary>
 /// The attach.
 /// </summary>
 /// <param name="interceptor">
 /// The interceptor.
 /// </param>
 /// <exception cref="NotImplementedException">
 /// </exception>
 public void Attach(IRequestInterceptor interceptor)
 {
     this._registeredInterceptors.Add(interceptor);
 }