Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
        }
Exemplo n.º 6
0
        public void Is_exception_thrown_when_methodinfo_is_null()
        {
            MethodSignatureDto methodSignature = MethodSignatureDto.FromMethod(null);

            Assert.IsNull(methodSignature);
        }