Mono.Cecil.Tests.PortablePdbTests.LocalConstants C# (CSharp) Method

LocalConstants() private method

private LocalConstants ( ) : void
return void
        public void LocalConstants()
        {
            TestPortablePdbModule (module => {
                var type = module.GetType ("PdbTarget.Program");
                var method = type.GetMethod ("Bar");
                var debug_info = method.DebugInformation;

                Assert.IsNotNull (debug_info.Scope);
                Assert.IsTrue (debug_info.Scope.HasScopes);
                Assert.AreEqual (2, debug_info.Scope.Scopes.Count);

                var scope = debug_info.Scope.Scopes [1];

                Assert.IsNotNull (scope);
                Assert.IsTrue (scope.HasConstants);
                Assert.AreEqual (2, scope.Constants.Count);

                var constant = scope.Constants [0];

                Assert.AreEqual ("b", constant.Name);
                Assert.AreEqual (12, constant.Value);
                Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType);

                constant = scope.Constants [1];
                Assert.AreEqual ("c", constant.Name);
                Assert.AreEqual ((decimal) 74, constant.Value);
                Assert.AreEqual (MetadataType.ValueType, constant.ConstantType.MetadataType);

                method = type.GetMethod ("Foo");
                debug_info = method.DebugInformation;

                Assert.IsNotNull (debug_info.Scope);
                Assert.IsTrue (debug_info.Scope.HasConstants);
                Assert.AreEqual (4, debug_info.Scope.Constants.Count);

                constant = debug_info.Scope.Constants [0];
                Assert.AreEqual ("s", constant.Name);
                Assert.AreEqual ("const string", constant.Value);
                Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType);

                constant = debug_info.Scope.Constants [1];
                Assert.AreEqual ("f", constant.Name);
                Assert.AreEqual (1, constant.Value);
                Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType);

                constant = debug_info.Scope.Constants [2];
                Assert.AreEqual ("o", constant.Name);
                Assert.AreEqual (null, constant.Value);
                Assert.AreEqual (MetadataType.Object, constant.ConstantType.MetadataType);

                constant = debug_info.Scope.Constants [3];
                Assert.AreEqual ("u", constant.Name);
                Assert.AreEqual (null, constant.Value);
                Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType);
            });
        }