DefineInstanceMethod() public method

public DefineInstanceMethod ( IMethod method ) : void
method IMethod
return void
Esempio n. 1
0
        public void DefineInstanceMethod()
        {
            IMetaClass meta = BaseMetaClass.CreateMetaClass(null, this.machine);
            BaseBehavior behavior = new BaseBehavior(meta, null, this.machine);
            IMethod method = new Method("method");

            behavior.DefineInstanceMethod(new Method("method"));

            IMethod result = behavior.GetInstanceMethod("method");
            Assert.IsNotNull(result);
            Assert.AreEqual("method", result.Name);
        }
Esempio n. 2
0
        public void AddBehaviorAsTrait()
        {
            BaseBehavior behavior = new BaseBehavior(null, null, this.machine);
            IMethod method = new Method("method");

            behavior.DefineInstanceMethod(method);

            BaseBehavior trait = new BaseBehavior(null, null, this.machine);
            IMethod method2 = new Method("method2");

            trait.DefineInstanceMethod(method2);

            behavior.AddTrait(trait);

            IMethod result = behavior.GetInstanceMethod("method");
            Assert.IsNotNull(result);
            Assert.AreSame(method, result);
            result = behavior.GetInstanceMethod("method2");
            Assert.IsNotNull(result);
            Assert.AreSame(method2, result);
        }
Esempio n. 3
0
        public void GetInstanceMethods()
        {
            BaseBehavior behavior = new BaseBehavior(null, null, this.machine);
            IMethod method = new Method("method");

            behavior.DefineInstanceMethod(new Method("method1"));
            behavior.DefineInstanceMethod(new Method("method2"));

            ICollection<IMethod> methods = behavior.GetInstanceMethods();

            Assert.IsNotNull(methods);
            Assert.AreEqual(2, methods.Count);
        }