public void GetsAllInterfaces() { // Extend to get new interface TestObjectSubclass raw = new TestObjectSubclass(); ProxyFactory factory = new ProxyFactory(raw); Assert.AreEqual(8, factory.Interfaces.Count, "Found correct number of interfaces"); //System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ",")); ITestObject tb = (ITestObject)factory.GetProxy(); Assert.IsTrue(tb is IOther, "Picked up secondary interface"); raw.Age = 25; Assert.IsTrue(tb.Age == raw.Age); DateTime t = new DateTime(2004, 8, 1); TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t); Console.WriteLine(StringUtils.CollectionToDelimitedString(factory.Interfaces, "/")); //factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped))); factory.AddIntroduction( new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped)) ); Console.WriteLine(StringUtils.CollectionToDelimitedString(factory.Interfaces, "/")); ITimeStamped ts = (ITimeStamped)factory.GetProxy(); Assert.IsTrue(ts.TimeStamp == t); // Shouldn't fail; ((IOther)ts).Absquatulate(); }
public void GetsAllInterfaces() { // Extend to get new interface TestObjectSubclass raw = new TestObjectSubclass(); ProxyFactory factory = new ProxyFactory(raw); Assert.AreEqual(8, factory.Interfaces.Length, "Found correct number of interfaces"); //System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ",")); ITestObject tb = (ITestObject)factory.GetProxy(); Assert.IsTrue(tb is IOther, "Picked up secondary interface"); raw.Age = 25; Assert.IsTrue(tb.Age == raw.Age); DateTime t = new DateTime(2004, 8, 1); TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t); Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/")); //factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped))); factory.AddIntroduction( new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped)) ); Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/")); ITimeStamped ts = (ITimeStamped)factory.GetProxy(); Assert.IsTrue(ts.TimeStamp == t); // Shouldn't fail; ((IOther)ts).Absquatulate(); }