public void DefaultDynamicLazyFieldInterceptorUnWrapsTIEExceptions() { var pf = new DefaultProxyFactory(); var propertyInfo = typeof(MyClass).GetProperty("Id"); pf.PostInstantiate("MyClass", typeof(MyClass), new HashSet<System.Type>(), propertyInfo.GetGetMethod(), propertyInfo.GetSetMethod(), null); var myClassProxied = (MyClass)pf.GetFieldInterceptionProxy(new MyClass()); Assert.Throws<FormatException>(() => myClassProxied.ThrowError(), "test"); }
public void LazyFieldInterceptorIsBinarySerializable() { var pf = new DefaultProxyFactory(); var propertyInfo = typeof(MyClass).GetProperty("Id"); pf.PostInstantiate("MyClass", typeof(MyClass), new HashSet<System.Type>(), propertyInfo.GetGetMethod(), propertyInfo.GetSetMethod(), null); var fieldInterceptionProxy = (IFieldInterceptorAccessor)pf.GetFieldInterceptionProxy(new MyClass()); fieldInterceptionProxy.FieldInterceptor = new DefaultFieldInterceptor(null, null, null, "MyClass", typeof(MyClass)); fieldInterceptionProxy.Should().Be.BinarySerializable(); }