示例#1
0
        public void DefineEvent_Adds_EventBuilder()
        {
            var moduleScope    = new ModuleScope();
            var generator      = new ProxyGenerator(moduleScope);
            var typeDefinition = generator.GetTypeDefinition(typeof(EmpyType), null, null);

            TypeBuilder typeBulder = moduleScope.Module.DefineType(typeDefinition.FullName, typeDefinition.TypeAttributes);

            var proxyScope = new ProxyScope(moduleScope, typeBulder, typeDefinition);

            proxyScope.DefineTypeAndMembers();

            Assert.AreEqual(0, proxyScope.Events.Count);

            var m = proxyScope.DefineEvent("E", EventAttributes.None, typeof(EventHandler));

            Assert.AreEqual(1, proxyScope.Events.Count);
            Assert.AreEqual("E", proxyScope.Events[0].GetName());
        }