public void ShortCircuit() { Recorder.Records.Clear(); SpyException rawObject = new SpyException(); MethodBase method = typeof(SpyException).GetMethod("InterceptedMethod"); Dictionary <MethodBase, List <IInterceptionHandler> > dictionary = new Dictionary <MethodBase, List <IInterceptionHandler> >(); List <IInterceptionHandler> handlers = new List <IInterceptionHandler>(); handlers.Add(new ShortCircuitHandler()); dictionary.Add(method, handlers); SpyException wrapped = RemotingInterceptor.Wrap(rawObject, dictionary); wrapped.InterceptedMethod(); // Does not throw because it was short circuited }
public void Exceptions() { Recorder.Records.Clear(); SpyException rawObject = new SpyException(); MethodBase method = typeof(SpyException).GetMethod("InterceptedMethod"); Dictionary <MethodBase, List <IInterceptionHandler> > dictionary = new Dictionary <MethodBase, List <IInterceptionHandler> >(); List <IInterceptionHandler> handlers = new List <IInterceptionHandler>(); handlers.Add(new RecordingHandler()); dictionary.Add(method, handlers); SpyException wrapped = RemotingInterceptor.Wrap(rawObject, dictionary); Assert.Throws <NotImplementedException>(delegate { wrapped.InterceptedMethod(); }); Assert.Equal(2, Recorder.Records.Count); Assert.Equal("Before Method", Recorder.Records[0]); Assert.Equal("After Method", Recorder.Records[1]); }