public void PropertyGetterValueType <T>(T expectedResult, T expectedValue) where T : struct { // Given var proxyFactory = Context.ProxyFactory; var interceptor = new PropertyInterceptor <T>(expectedResult); // When var foo = proxyFactory.CreateForInterface <IFooValueTypeProperty <T> >(interceptor); var result = foo.GetterSetter; foo.GetterSetter = expectedValue; // Then Assert.NotNull(foo); Assert.Equal(2, interceptor.ForwardedInvocations.Count); var invocation = interceptor.ForwardedInvocations.First(); invocation.ShouldInterceptPropertyWithName(nameof(IFooValueTypeProperty <T> .GetterSetter)); invocation.ShouldHaveReturnValue(expectedResult); Assert.Equal(expectedResult, result); invocation = interceptor.ForwardedInvocations.Last(); invocation.ShouldInterceptPropertyWithName(nameof(IFooValueTypeProperty <T> .GetterSetter)); invocation.ShouldHavePropertyValue(typeof(T), expectedValue); }
public void PropertyIndexedGetterValueType <T>(T expectedResult, T expectedValue) where T : struct { // Given var proxyFactory = Context.ProxyFactory; var interceptor = new PropertyInterceptor <T>(expectedResult); // When var foo = proxyFactory.CreateForInterface <IFooValueTypeIndexedProperty <T> >(interceptor); var result = foo[expectedValue]; foo[expectedValue] = expectedResult; // Then Assert.NotNull(foo); Assert.Equal(2, interceptor.ForwardedInvocations.Count); var invocation = interceptor.ForwardedInvocations.First(); invocation.ShouldInterceptPropertyWithName("Item"); invocation.ShouldHaveReturnValue(expectedResult); Assert.Equal(expectedResult, result); invocation.ShouldHaveParameterInCountOf(1); invocation.ShouldHaveParameterIn("first", typeof(T), expectedValue); invocation = interceptor.ForwardedInvocations.Last(); invocation.ShouldInterceptPropertyWithName("Item"); invocation.ShouldHavePropertyValue(typeof(T), expectedResult); invocation.ShouldHaveParameterInCountOf(1); invocation.ShouldHaveParameterIn("first", typeof(T), expectedValue); }
public void PropertyIndexedGetterValueTypeWithSecondOverload <T>(T expectedResult, T expectedValue) where T : struct { // Given var proxyFactory = Context.ProxyFactory; var interceptor = new PropertyInterceptor <T>(expectedResult); // When var foo = proxyFactory.CreateForInterface <IFooValueTypeIndexedOverload <T> >(interceptor); var result = foo[expectedValue, default];