Exemple #1
0
        public void ProxyContextReturnsTrueIfTypeHasBeenProxied() {
            var context = new DynamicProxyContext();

            Type proxyType;
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.False);
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.False);
            Assert.That(proxyType, Is.Null);

            context.AddProxy(typeof(SimpleComponent));
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(proxyType, Is.Not.Null);
        }
Exemple #2
0
        public void AddProxyCanBeCalledMoreThanOnce() {
            var context = new DynamicProxyContext();
            context.AddProxy(typeof(SimpleComponent));

            Type proxyType;
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(proxyType, Is.Not.Null);

            Type proxyType2;
            context.AddProxy(typeof(SimpleComponent));
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType2), Is.True);

            Assert.That(proxyType2, Is.SameAs(proxyType));
        }
        public void ProxyContextReturnsTrueIfTypeHasBeenProxied()
        {
            var context = new DynamicProxyContext();

            Type proxyType;

            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.False);
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.False);
            Assert.That(proxyType, Is.Null);

            context.AddProxy(typeof(SimpleComponent));
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(proxyType, Is.Not.Null);
        }
        public void AddProxyCanBeCalledMoreThanOnce()
        {
            var context = new DynamicProxyContext();

            context.AddProxy(typeof(SimpleComponent));

            Type proxyType;

            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(proxyType, Is.Not.Null);

            Type proxyType2;

            context.AddProxy(typeof(SimpleComponent));
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType2), Is.True);

            Assert.That(proxyType2, Is.SameAs(proxyType));
        }
Exemple #5
0
        public void InterceptorAddedToContextFromModules() {
            var context = new DynamicProxyContext();

            var builder = new ContainerBuilder();
            builder.RegisterType<SimpleComponent>().EnableDynamicProxy(context);
            builder.RegisterModule(new SimpleInterceptorModule());

            builder.Build();

            Type proxyType;
            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(proxyType, Is.Not.Null);
        }
        public void InterceptorAddedToContextFromModules()
        {
            var context = new DynamicProxyContext();

            var builder = new ContainerBuilder();

            builder.RegisterType <SimpleComponent>().EnableDynamicProxy(context);
            builder.RegisterModule(new SimpleInterceptorModule());

            builder.Build();

            Type proxyType;

            Assert.That(context.TryGetProxy(typeof(SimpleComponent), out proxyType), Is.True);
            Assert.That(proxyType, Is.Not.Null);
        }