public void CanProxyBasicGenericMethod() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); Assert.That(c.BasicGenericMethod<int>(), Is.EqualTo(5)); Assert.That(c.BasicGenericMethod<string>(), Is.EqualTo("blha")); }
public void CanProxyBasicGenericMethod() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); c.BasicGenericMethod<int>().Should().Be(5); c.BasicGenericMethod<string>().Should().Be("blha"); }
public void WhenProxyAnInterfaceShouldInterceptEquals() { var proxyFactory = new ProxyFactory(); var interceptor = new InterceptedMethodsExposer(); var proxy = proxyFactory.CreateProxy(typeof(IHasSomething), interceptor, null); proxy.Equals(null); Assert.That(interceptor.InterceptedMethods, Contains.Item("Equals")); }
public void Proxy() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); var dictionary = new Dictionary<string, string>(); var myParam = dictionary; c.Method(ref myParam); Assert.That(myParam, Is.Not.SameAs(dictionary)); }
public void Proxy() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); var dictionary = new Dictionary<string, string>(); var myParam = dictionary; c.Method(ref myParam); myParam.Should().Not.Be.SameInstanceAs(dictionary); }
public void Proxy() { var factory = new ProxyFactory(); var c = (ClassWithVarietyOfMembers)factory.CreateProxy(typeof(ClassWithVarietyOfMembers), new PassThroughInterceptor(new ClassWithVarietyOfMembers()), null); int x; c.Method1(out x); Assert.AreEqual(3, x); x = 4; c.Method2(ref x); Assert.AreEqual(5, x); }
public void CanProxyGenericMethodWithReferenceTypeAndInterfaceConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyDerivedClass()), null); c.MethodWithReferenceTypeAndInterfaceConstraint<MyDerivedClass>().Should().Not.Be.Null(); }
public void CanProxyGenericMethodWithInterfaceConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); c.MethodWithInterfaceConstraint<IMyInterface>(new MyDerivedClass()).Should().Be(typeof(IMyInterface)); }
public void CanProxyMethodWithDefaultConstructorConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); c.MethodWithConstructorConstraint<MyClass>().Should().Not.Be.Null(); }
public void CanProxySelfCastingMethod() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); c.As<MyClass>().Should().Not.Be.Null(); }
public void CanProxyMethodWithGenericBaseClassConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); c.MethodWithGenericBaseClassConstraint<MyGenericClass<int>, int>().Should().Be(typeof(MyGenericClass<int>)); }
public void CanProxySelfCastingMethodWithGenericConstaintBase2() { var factory = new ProxyFactory(); var c = (MyGenericClass<int>) factory.CreateProxy(typeof (MyGenericClass<int>), new PassThroughInterceptor(new MyGenericClass<int>()), null); c.AsBase2<MyGenericClass<object>>().Should().Not.Be.Null(); }
public void CanProxySelfCastingMethodWithGenericConstaint2() { var factory = new ProxyFactory(); var c = (MyGenericClass<int>) factory.CreateProxy(typeof (MyGenericClass<int>), new PassThroughInterceptor(new MyGenericClass<int>()), null); Assert.That(c.As2<MyGenericClass<object>>(), Is.Not.Null); }
public void CanProxyGenericMethodWithInterfaceConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); Assert.That(c.MethodWithInterfaceConstraint<IMyInterface>(new MyDerivedClass()), Is.EqualTo(typeof(IMyInterface))); }
public void CanProxySelfCastingMethod() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); Assert.That(c.As<MyClass>(), Is.Not.Null); }
public void CanProxyMethodWithGenericBaseClassConstraint() { var factory = new ProxyFactory(); var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null); Assert.That(c.MethodWithGenericBaseClassConstraint<MyGenericClass<int>, int>(), Is.EqualTo(typeof(MyGenericClass<int>))); }