コード例 #1
0
ファイル: TableTest.cs プロジェクト: DamienHauta/Ns2Docs
        public void AllMethods__Dont_Include___prepareclass_From_Parent_Tables()
        {
            Table cls = new Table("Class");
            Table mixin = new Table("Mixin");
            cls.Mixins.Add(mixin);

            IMethod __prepareclass = MockRepository.GenerateStub<IMethod>();
            __prepareclass.Expect(x => x.Table).Return(mixin);
            __prepareclass.Expect(x => x.Name).Return("__initmixin");
            __prepareclass.Expect(x => x.ExistsOnServer).Return(true);
            mixin.Methods.Add(__prepareclass);

            IMethod[] allMethods = cls.AllMethods().ToArray();

            Assert.IsEmpty(cls.AllMethods().ToArray());
        }
コード例 #2
0
ファイル: TableTest.cs プロジェクト: DamienHauta/Ns2Docs
        public void AllMethods()
        {
            Table weapon = new Table("Weapon");
            Table clipWeapon = new Table("ClipWeapon", weapon);

            IMethod getCanIdle = MockRepository.GenerateStub<IMethod>();
            getCanIdle.Expect(x => x.ExistsOnClient).Return(true);
            getCanIdle.Expect(x => x.ExistsOnServer).Return(true);
            weapon.Methods.Add(getCanIdle);

            Assert.Contains(getCanIdle, clipWeapon.AllMethods().ToArray());
        }
コード例 #3
0
ファイル: TableTest.cs プロジェクト: DamienHauta/Ns2Docs
        public void AllMethods__Include__Mixin__Methods()
        {
            Table mac = new Table("MAC");
            Table upgradeableMixin = new Table("UpgradableMixin");
            mac.Mixins.Add(upgradeableMixin);

            IMethod getUpgrades = MockRepository.GenerateStub<IMethod>();
            getUpgrades.Expect(x => x.Table).Return(upgradeableMixin);
            getUpgrades.Expect(x => x.Name).Return("GetUpgrades");
            getUpgrades.Expect(x => x.ExistsOnServer).Return(true);
            upgradeableMixin.Methods.Add(getUpgrades);

            Assert.AreEqual(getUpgrades, mac.AllMethods().First());
        }
コード例 #4
0
ファイル: TableTest.cs プロジェクト: DamienHauta/Ns2Docs
        public void AllMethods__Ignore_Overridden_Methods()
        {
            Table weapon = new Table("Weapon");
            Table clipWeapon = new Table("ClipWeapon", weapon);

            IMethod getCanIdle_Weapon = MockRepository.GenerateStub<IMethod>();
            getCanIdle_Weapon.Expect(x => x.Name).Return("GetCanIdle");
            getCanIdle_Weapon.Expect(x => x.ExistsOnServer).Return(true);
            weapon.Methods.Add(getCanIdle_Weapon);

            IMethod getCanIdle_ClipWeapon = MockRepository.GenerateStub<IMethod>();
            getCanIdle_ClipWeapon.Expect(x => x.Name).Return("GetCanIdle");
            getCanIdle_ClipWeapon.Expect(x => x.ExistsOnServer).Return(true);
            clipWeapon.Methods.Add(getCanIdle_ClipWeapon);

            IMethod[] allMethods = clipWeapon.AllMethods().ToArray();

            Assert.Contains(getCanIdle_ClipWeapon, allMethods);
            Assert.AreEqual(1, allMethods.Length, "Only contain ClipWeapon:CanIdle() because Weapon:CanIdle() is overridden.");
            Assert.IsFalse(allMethods.Contains(getCanIdle_Weapon));
        }
コード例 #5
0
ファイル: TableTest.cs プロジェクト: DamienHauta/Ns2Docs
        public void AllMethods__Use_Nearest_Parent_Method_For_Methods_That_Are_Not_Overridden()
        {
            Table scriptActor = new Table("ScriptActor");
            Table weapon = new Table("Weapon", scriptActor);
            Table clipWeapon = new Table("ClipWeapon", weapon);

            IMethod onCreate_ScriptActor = MockRepository.GenerateStub<IMethod>();
            onCreate_ScriptActor.Expect(x => x.Name).Return("OnCreate");
            onCreate_ScriptActor.Expect(x => x.Table).Return(scriptActor);
            onCreate_ScriptActor.Expect(x => x.ExistsOnServer).Return(true);
            scriptActor.Methods.Add(onCreate_ScriptActor);

            IMethod onCreate_Weapon = MockRepository.GenerateStub<IMethod>();
            onCreate_Weapon.Expect(x => x.Name).Return("OnCreate");
            onCreate_Weapon.Expect(x => x.Table).Return(weapon);
            onCreate_Weapon.Expect(x => x.ExistsOnServer).Return(true);
            weapon.Methods.Add(onCreate_Weapon);

            IEnumerable<IMethod> allMethods = clipWeapon.AllMethods();

            Assert.AreEqual(1, allMethods.Count());
            Assert.AreEqual(onCreate_Weapon, allMethods.First());
        }