示例#1
0
        private void AssertAllMethodsRegistered(MethodInfoBasedNodeTypeRegistry registry, Type type)
        {
            var supportedMethodsField = type.GetField("SupportedMethods");

            if (supportedMethodsField != null)
            {
                var methodInfos = (MethodInfo[])supportedMethodsField.GetValue(null);
                Assert.That(methodInfos.Length, Is.GreaterThan(0));

                foreach (var methodInfo in methodInfos)
                {
                    Assert.That(registry.GetNodeType(methodInfo), Is.SameAs(type));
                }
            }

            var supportedMethodNamesField = type.GetField("SupportedMethodNames");

            if (supportedMethodNamesField != null)
            {
                var methodNames = (string[])supportedMethodNamesField.GetValue(null);
                Assert.That(methodNames.Length, Is.GreaterThan(0));

                foreach (var methodName in methodNames)
                {
                    Assert.That(registry.GetNodeType(type.GetMethod(methodName)), Is.SameAs(type));
                }
            }
        }
示例#2
0
        public void Test_WithMethodInfo()
        {
            _registry.Register(SelectExpressionNode.GetSupportedMethods(), typeof(SelectExpressionNode));

            var type = _registry.GetNodeType(SelectExpressionNode.GetSupportedMethods().First());

            Assert.That(type, Is.SameAs(typeof(SelectExpressionNode)));
        }