Esempio n. 1
0
        public void ReadsParameter_InstanceMethodLdarg1_ReturnsFirstParameter()
        {
            var subject = new InstructionHelper();

            Parameter parameter;
            bool result = subject.ReadsParameter(InstanceMethodReference,
                Instruction.Create(OpCodes.Ldarg_1), out parameter);

            Assert.IsTrue(result);
            Assert.AreEqual(1, parameter.Index);
            Assert.AreEqual(typeof(int).FullName, parameter.ParameterType.FullName);
        }
Esempio n. 2
0
        public void ReadsParameter_StaticMethodLdarg_ReturnsSpecifiedParameter(
            int parameterIndex, Type expectedType)
        {
            var subject = new InstructionHelper();

            Parameter parameter;
            var instruction = Instruction.Create(OpCodes.Ldarg,
                StaticMethodReference.Parameters[parameterIndex]);
            bool result = subject.ReadsParameter(StaticMethodReference, instruction, out parameter);

            Assert.IsTrue(result);
            Assert.AreEqual(parameterIndex, parameter.Index);
            Assert.AreEqual(expectedType.FullName, parameter.ParameterType.FullName);
        }
Esempio n. 3
0
        public void ReadsParameter_StaticMethodLdarg3_ReturnsFourthParameter()
        {
            var subject = new InstructionHelper();

            Parameter parameter;
            bool result = subject.ReadsParameter(StaticMethodReference,
                Instruction.Create(OpCodes.Ldarg_3), out parameter);

            Assert.IsTrue(result);
            Assert.AreEqual(3, parameter.Index);
            Assert.AreEqual(typeof(double).FullName, parameter.ParameterType.FullName);
        }