Exemplo n.º 1
0
        public void GetPropertyInfoProp()
        {
            // Regression test for (internal). Use a decorated factory since
            // propertyInfo.pProperty should be the decorated object.
            var decoratorUtil = new DecoratorUtil(
                new ProxyGenerationOptions(new DebugEngineProxyHook()));

            // Needs at least one aspect or else decorator is not assigned to Self.
            IDecorator factoryDecorator = decoratorUtil.CreateFactoryDecorator(
                new ProxyGenerator(), new NoopAspect());

            DebugAsyncProperty.Factory decoratedPropertyFactory =
                factoryDecorator.Decorate(propertyFactory);

            IGgpAsyncDebugProperty decoratedDebugProperty =
                decoratedPropertyFactory.Create(mockVarInfo);

            DEBUG_PROPERTY_INFO propertyInfo;

            decoratedDebugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP,
                                                   out propertyInfo);

            Assert.That(
                propertyInfo.dwFields.HasFlag(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP));

            Assert.That(propertyInfo.pProperty, Is.SameAs(decoratedDebugProperty));
        }
        /// <summary>
        /// Gets decorator used for Debug object factories and other factories for types
        /// that we want to wrap with aspects provided by CreateApiAspects().
        /// </summary>
        public IDecorator GetFactoryDecorator()
        {
            if (_factoryDecorator == null)
            {
                var decoratorUtil =
                    new DecoratorUtil(new ProxyGenerationOptions(new DebugEngineProxyHook()));
                _factoryDecorator = decoratorUtil.CreateFactoryDecorator(
                    new ProxyGenerator(), CreateApiAspects().ToArray());
            }

            return(_factoryDecorator);
        }
Exemplo n.º 3
0
        public void FactoryDecoratorShouldNotModifyObjectWithEmptyAspectsList()
        {
            var factoryDecorator = classUnderTest.CreateFactoryDecorator(
                proxyGenerator);

            var decoratedFactory = factoryDecorator.Decorate(factory);

            Assert.AreSame(factory, decoratedFactory);
        }
Exemplo n.º 4
0
        public void CompareEqualWithProxy()
        {
            var proxyGenerator = new Castle.DynamicProxy.ProxyGenerator();
            var decoratorUtil  = new DecoratorUtil();

            // Create the factory.
            var factory = new DebugMemoryContext.Factory();

            // Decorate the factory with a dummy aspect.
            var aspect           = new YetiCommon.Tests.CastleAspects.TestSupport.CallCountAspect();
            var factoryDecorator = decoratorUtil.CreateFactoryDecorator(proxyGenerator, aspect);
            var factoryWithProxy = factoryDecorator.Decorate(factory);

            var memoryContextWithProxy = factoryWithProxy.Create(TEST_PC, TEST_NAME);

            // Check all the combinations of comparing proxied and non-proxied memory context.
            uint matchIndex;

            Assert.AreEqual(VSConstants.S_OK, memoryContextWithProxy.Compare(
                                enum_CONTEXT_COMPARE.CONTEXT_EQUAL,
                                new IDebugMemoryContext2[1] {
                memoryContextWithProxy
            }, 1, out matchIndex));
            Assert.AreEqual(0, matchIndex);

            Assert.AreEqual(VSConstants.S_OK, memoryContext.Compare(
                                enum_CONTEXT_COMPARE.CONTEXT_EQUAL,
                                new IDebugMemoryContext2[1] {
                memoryContextWithProxy
            }, 1, out matchIndex));
            Assert.AreEqual(0, matchIndex);

            Assert.AreEqual(VSConstants.S_OK, memoryContextWithProxy.Compare(
                                enum_CONTEXT_COMPARE.CONTEXT_EQUAL,
                                new IDebugMemoryContext2[1] {
                memoryContext
            }, 1, out matchIndex));
            Assert.AreEqual(0, matchIndex);
        }
Exemplo n.º 5
0
        public void AspectOrderIsInvocationOrderOnFactoryCreatedObjects()
        {
            var callOrder          = new List <int>();
            var invocationCallback = (Action <int>)((id) =>
            {
                callOrder.Add(id);
            });
            var aspects = new IInterceptor[]
            {
                new CallOrderAspect(0, invocationCallback),
                new CallOrderAspect(1, invocationCallback)
            };
            var factoryDecorator = decoratorUtil.CreateFactoryDecorator(proxyGenerator, aspects);
            var decoratedFactory = factoryDecorator.Decorate(factory);
            var dummyObj         = decoratedFactory.Create();

            dummyObj.GetValue();

            Assert.That(callOrder.Count, Is.EqualTo(2));
            Assert.That(callOrder[0], Is.EqualTo(0));
            Assert.That(callOrder[1], Is.EqualTo(1));
        }