public void WhereClauseOnMethod() { Recorder.Records.Clear(); RecordingHandler handler = new RecordingHandler(); MethodBase method = typeof(INonGenericSpy).GetMethod("WhereMethod"); Dictionary <MethodBase, List <IInterceptionHandler> > dictionary = new Dictionary <MethodBase, List <IInterceptionHandler> >(); List <IInterceptionHandler> handlers = new List <IInterceptionHandler>(); handlers.Add(handler); dictionary.Add(method, handlers); INonGenericSpy result = WrapAndCreateType <INonGenericSpy, NonGenericSpy>(dictionary); result.WhereMethod(new Foo()); Assert.Equal(3, Recorder.Records.Count); Assert.Equal("Before Method", Recorder.Records[0]); Assert.Equal("In method with data " + typeof(Foo).FullName, Recorder.Records[1]); Assert.Equal("After Method", Recorder.Records[2]); }
public void ReturnsDataOfGenericType() { Recorder.Records.Clear(); RecordingHandler handler = new RecordingHandler(); MethodBase method = typeof(INonGenericSpy).GetMethod("GenericReturn"); Dictionary <MethodBase, List <IInterceptionHandler> > dictionary = new Dictionary <MethodBase, List <IInterceptionHandler> >(); List <IInterceptionHandler> handlers = new List <IInterceptionHandler>(); handlers.Add(handler); dictionary.Add(method, handlers); INonGenericSpy result = WrapAndCreateType <INonGenericSpy, NonGenericSpy>(dictionary); int value = result.GenericReturn <int, double>(256.9); Assert.Equal(3, Recorder.Records.Count); Assert.Equal("Before Method", Recorder.Records[0]); Assert.Equal("In method with data 256.9", Recorder.Records[1]); Assert.Equal("After Method", Recorder.Records[2]); Assert.Equal(default(int), value); }