PageRenderTime 109ms CodeModel.GetById 27ms app.highlight 3ms RepoModel.GetById 78ms app.codeStats 0ms

/src/UnitTests/AOP/ParameterDefinitionExtensionTests.cs

http://github.com/philiplaureano/LinFu
C# | 35 lines | 28 code | 5 blank | 2 comment | 0 complexity | 8ae2a9fe7ed413ef14c238a9ea0307d0 MD5 | raw file
 1using LinFu.Reflection.Emit;
 2using Mono.Cecil;
 3using Xunit;
 4using SampleLibrary.AOP;
 5
 6namespace LinFu.UnitTests.AOP
 7{
 8    public class ParameterDefinitionExtensionTests : BaseTestFixture
 9    {
10        [Fact]
11        public void ShouldBeAbleToDetermineIfMethodIsByRef()
12        {
13            var location = typeof(SampleClassWithByRefMethod).Assembly.Location;
14            var assembly = AssemblyDefinition.ReadAssembly(location);
15            var module = assembly.MainModule;
16
17            var targetType = module.GetType("SampleClassWithByRefMethod");
18            var byRefMethod = targetType.GetMethod("ByRefMethod");
19            var regularMethod = targetType.GetMethod("NonByRefMethod");
20
21            Assert.NotNull(assembly);
22            Assert.NotNull(targetType);
23            Assert.NotNull(byRefMethod);
24            Assert.NotNull(regularMethod);
25
26            // Test the byref parameter
27            var parameter = byRefMethod.Parameters[0];
28            Assert.True(parameter.IsByRef());
29
30            // Test the non-byref parameter
31            parameter = regularMethod.Parameters[0];
32            Assert.False(parameter.IsByRef());
33        }
34    }
35}