예제 #1
0
        public void ShouldReturnMethodsFromAgent()
        {
            Type mockProxyAgentType = typeof(MockProxyAgent);
            Type mockProxyType      = typeof(MockProxy);

            List <MethodInfo> methods = MethodBehaviorHelper.GetAgentMethods(mockProxyAgentType, mockProxyType);

            Assert.IsTrue(methods.Contains(mockProxyType.GetMethod("HelloWorld", new Type[] {})));
            Assert.IsTrue(methods.Contains(mockProxyType.GetMethod("HelloWorld", new Type[] { typeof(string) })));
            Assert.IsTrue(methods.Contains(mockProxyType.GetMethod("Foo", new Type[] {})));
        }
예제 #2
0
        public void ShouldReturnSameMethodsFromAgentThanProxy()
        {
            Type mockProxyAgentType = typeof(MockProxyAgent);
            Type mockProxyType      = typeof(MockProxy);

            List <MethodInfo> agentMethods = MethodBehaviorHelper.GetAgentMethods(mockProxyAgentType, mockProxyType);

            Assert.AreEqual(3, agentMethods.Count);
            Assert.IsFalse(
                agentMethods.Contains(mockProxyAgentType.GetMethod("HelloWorld", new Type[] { typeof(OfflineBehavior) })));
            Assert.IsFalse(
                agentMethods.Contains(
                    mockProxyAgentType.GetMethod("HelloWorld", new Type[] { typeof(string), typeof(OfflineBehavior) })));
            Assert.IsFalse(agentMethods.Contains(mockProxyAgentType.GetMethod("Foo", new Type[] { typeof(OfflineBehavior) })));
        }
예제 #3
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            newValue = null;
            if (currentValue == null)
            {
                CodeClass currentDSAClass = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                          currentDSAClassExpression) as CodeClass;
                Type proxyType = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                               proxyTypeExpression) as Type;

                if (currentDSAClass != null && proxyType != null)
                {
                    Type dsaType = DteConverter.ToType(currentDSAClass);
                    if (dsaType != null)
                    {
                        newValue = MethodBehaviorHelper.GetMethodNames(MethodBehaviorHelper.GetAgentMethods(dsaType, proxyType));
                    }
                }
            }
            return(currentValue != newValue);
        }