public void PropertyGetterReferenceType <T>(T?expectedResult) where T : class { // Given var proxyFactory = Context.ProxyFactory; var interceptor = new GetterInterceptor <T>(expectedResult); // When var foo = proxyFactory.CreateForInterface <IFooReferenceTypeGetter <T> >(interceptor); var result = foo.Getter; // Then Assert.NotNull(foo); Assert.Single(interceptor.ForwardedInvocations); var invocation = interceptor.ForwardedInvocations.Single(); invocation.ShouldInterceptPropertyWithName(nameof(IFooReferenceTypeGetter <T> .Getter)); invocation.ShouldHaveReturnValue(expectedResult); Assert.Equal(expectedResult, result); }
public void PropertyIndexedGetterValueType <T>(T expectedResult, T expectedValue) where T : struct { // Given var proxyFactory = Context.ProxyFactory; var interceptor = new GetterInterceptor <T>(expectedResult); // When var foo = proxyFactory.CreateForInterface <IFooValueTypeIndexedGetter <T> >(interceptor); var result = foo[expectedValue]; // Then Assert.NotNull(foo); Assert.Single(interceptor.ForwardedInvocations); var invocation = interceptor.ForwardedInvocations.Single(); invocation.ShouldInterceptPropertyWithName("Item"); invocation.ShouldHaveParameterInCountOf(1); invocation.ShouldHaveParameterIn("first", typeof(T), expectedValue); invocation.ShouldHaveReturnValue(expectedResult); Assert.Equal(expectedResult, result); }