public void Emit_Nop_ThrowsException()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Nop);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
Beispiel #2
0
 public void Emit_Ldarg_ReturnsArgument()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldarg, 0);
     var result = (int)generator.ExecuteUsingOneArgument(42);
     Assert.AreEqual(42, result);
 }
        public void Emit_IntWithInvalidOpCode_ThrowsException()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldarg_0, 42);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
        public void Emit_MethodInfoWithInvalidOpCode_ThrowsException()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldarg, (MethodInfo)null);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
Beispiel #5
0
        public void Emit_Byte_ReturnsByte()
        {
            var generator = new ILGenerator();
            generator.Emit(OpCodes.Ldc_I4_S, (byte)42);
            var result = (int)generator.ExecuteUsingOneArgument(new object[] { });
            Assert.AreEqual(42, result);

        }
        public void Emit_LocalBuilderWithInvalidOpCode_ThrowsException()
        {
            var generator = new ILGenerator();
            var local     = generator.DeclareLocal(typeof(int));

            generator.Emit(OpCodes.Ldarg, local);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
        public void Emit_Ldarg_ReturnsArgument()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldarg, 0);
            var result = (int)generator.ExecuteUsingOneArgument(42);

            Assert.AreEqual(42, result);
        }
        public void Emit_Byte_ReturnsByte()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldc_I4_S, (byte)42);
            var result = (int)generator.ExecuteUsingOneArgument(new object[] { });

            Assert.AreEqual(42, result);
        }
        public void Emit_Ldc_I4_8_ReturnsValue()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldc_I4_8);
            var result = (int)generator.ExecuteUsingOneArgument(new object[] { });

            Assert.AreEqual(8, result);
        }
Beispiel #10
0
 public void Emit_Ldloc_0_ReturnsValue()
 {
     var generator = new ILGenerator();
     generator.DeclareLocal(typeof(int));
     generator.Emit(OpCodes.Ldarg, 0);
     generator.Emit(OpCodes.Stloc_0);
     generator.Emit(OpCodes.Ldloc_0);
     var result = (int)generator.ExecuteUsingOneArgument(42);
     Assert.AreEqual(42, result);
 }
        public void Emit_Ldloc_0_ReturnsValue()
        {
            var generator = new ILGenerator();

            generator.DeclareLocal(typeof(int));
            generator.Emit(OpCodes.Ldarg, 0);
            generator.Emit(OpCodes.Stloc_0);
            generator.Emit(OpCodes.Ldloc_0);
            var result = (int)generator.ExecuteUsingOneArgument(42);

            Assert.AreEqual(42, result);
        }
Beispiel #12
0
 public void Emit_Nop_ThrowsException()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Nop);
     generator.ExecuteUsingOneArgument(new object[] { });
 }
Beispiel #13
0
 public void Emit_Ldc_I4_8_ReturnsValue()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldc_I4_8);
     var result = (int)generator.ExecuteUsingOneArgument(new object[] { });
     Assert.AreEqual(8, result);
 }
Beispiel #14
0
 public void Emit_IntWithInvalidOpCode_ThrowsException()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldarg_0, 42);
     generator.ExecuteUsingOneArgument(new object[] { });
 }
Beispiel #15
0
 public void Emit_LocalBuilderWithInvalidOpCode_ThrowsException()
 {
     var generator = new ILGenerator();
     var local = generator.DeclareLocal(typeof(int));
     generator.Emit(OpCodes.Ldarg, local);
     generator.ExecuteUsingOneArgument(new object[] { });
 }
Beispiel #16
0
 public void Emit_MethodInfoWithInvalidOpCode_ThrowsException()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldarg, (MethodInfo)null);
     generator.ExecuteUsingOneArgument(new object[] { });
 }