public void CanInterceptMethods() { var type = typeof (AlternateTypeGenerationHookShould); var methodInfo = type.GetMethod("CanInterceptMethods"); var implementationMock = new Mock<IAlternateMethod>(); implementationMock.Setup(i => i.MethodToImplement).Returns(methodInfo); var alternateImplementations = new List<IAlternateMethod>(); alternateImplementations.Add(implementationMock.Object); var loggerMock = new Mock<ILogger>(); var hook = new AlternateTypeGenerationHook<ITab>(alternateImplementations, loggerMock.Object); var result = hook.ShouldInterceptMethod(type, methodInfo); Assert.True(result); }
public void NotInterceptMethodsWithMismatch() { var type = typeof(AlternateTypeGenerationHookShould); var methodInfo = type.GetMethod("CanInterceptMethods"); var implementationMock = new Mock <IAlternateMethod>(); implementationMock.Setup(i => i.MethodToImplement).Returns(methodInfo); var alternateImplementations = new List <IAlternateMethod>(); alternateImplementations.Add(implementationMock.Object); var loggerMock = new Mock <ILogger>(); var hook = new AlternateTypeGenerationHook <ITab>(alternateImplementations, loggerMock.Object); var result = hook.ShouldInterceptMethod(type, type.GetMethod("NotInterceptMethodsWithMismatch")); Assert.False(result); }