Пример #1
0
        public void Is_MethodSignature_name_set()
        {
            Type       currentType    = GetType();
            MethodInfo testMethodInfo = currentType.GetMethod("TestMethod");

            MethodSignatureDto methodSignature = MethodSignatureDto.FromMethod(testMethodInfo);

            Assert.AreEqual(testMethodInfo.Name, methodSignature.MethodName);
        }
Пример #2
0
        public void Can_initialize_MethodSignature_from_method_info()
        {
            Type       currentType    = GetType();
            MethodInfo testMethodInfo = currentType.GetMethod("TestMethod");

            MethodSignatureDto methodSignature = MethodSignatureDto.FromMethod(testMethodInfo);

            Assert.IsNotNull(methodSignature);
        }
Пример #3
0
        public void Is_declaring_type_correct()
        {
            Type               currentType     = GetType();
            MethodInfo         testMethodInfo  = currentType.GetMethod("TestMethod");
            MethodSignatureDto methodSignature = MethodSignatureDto.FromMethod(testMethodInfo);

            var actualAssemblyName   = methodSignature.DeclaringType.Assemblyname;
            var expectedAssemblyName = currentType.Assembly.FullName;

            var actualClassName   = methodSignature.DeclaringType.ClassName;
            var expectedClassName = currentType.FullName;

            Assert.AreEqual(actualAssemblyName, expectedAssemblyName);
            Assert.AreEqual(actualClassName, expectedClassName);
        }
Пример #4
0
        private static void SendExampleMethodSignature()
        {
            Type       type       = typeof(Program);
            MethodInfo methodInfo = type.GetMethod("ExampleMethod");

            MethodSignatureDto method = MethodSignatureDto.FromMethod(methodInfo);


            ISocketMessage socketMessage = new JsonSocketMessage();

            socketMessage.MessageType = SocketMessageType.Method;
            socketMessage.Message     = MethodSignatureDto.SerializeMethodObject(method);

            CommunicationClient.Send(socketMessage);
        }
Пример #5
0
        /// <summary>
        /// Gets the MethodSignatureDto of a specific method within a Type.
        /// <see cref="MethodSignatureDto"/> for more information about the DTO.
        /// </summary>
        /// <param name="type">Type to get MethodSignature from</param>
        /// <param name="methodName">The method within type to get MethodSignatureDto for</param>
        /// <returns></returns>
        public static MethodSignatureDto GetMethodSignature(this Type type, string methodName)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type), "The provided type cannot be null");
            }

            if (methodName == "")
            {
                throw new ArgumentException("The provided methodName cannot be empty", methodName);
            }

            if (methodName == null)
            {
                throw new ArgumentNullException(nameof(methodName), "The provided methodName cannot be null");
            }

            return(MethodSignatureDto.FromMethod(type.GetMethod(methodName)));
        }
Пример #6
0
        public void Is_exception_thrown_when_methodinfo_is_null()
        {
            MethodSignatureDto methodSignature = MethodSignatureDto.FromMethod(null);

            Assert.IsNull(methodSignature);
        }