Esempio n. 1
0
        public void AddInterceptorAtRuntime_Test()
        {
            Person per = new ProxyGenerator().CreateClassProxy <Person>();

            per.FirstName = "Foo";
            per.LastName  = "Bar";

            // by the current implementation the object have to be registered before it can be recognized as a freezable!
            Assert.IsFalse(Freezable.IsFreezable(per));

            Assert.IsFalse(Freezable.RegisterFreezable(per));

            ProxyHelper.AddInterceptor <FreezableInterceptor>(per);

            Assert.IsTrue(Freezable.RegisterFreezable(per));

            Assert.IsTrue(Freezable.IsFreezable(per));
        }
Esempio n. 2
0
        public void AddCountInterceptorAtRuntime_Test()
        {
            Person per = new ProxyGenerator().CreateClassProxy <Person>();

            per.FirstName = "Foo";
            per.LastName  = "Bar";

            var counter = new CounterInterceptor();

            ProxyHelper.AddInterceptor(per, counter);

            Assert.AreEqual(1, ProxyHelper.GetInterceptorsField(per).Count());

            Assert.AreEqual(per.FirstName, "Foo");
            Assert.AreEqual(per.LastName, "Bar");

            Assert.AreEqual(2, counter.CallsCount);
        }