Пример #1
0
        public Profiler(string name)
        {
            var script = App.GetNWScript();

            _nwnxProfiler = new NWNXProfiler(script);
            _nwnxProfiler.PushPerfScope(name);
        }
Пример #2
0
 public DurabilityService(
     INWScript script,
     IColorTokenService color,
     INWNXProfiler nwnxProfiler)
 {
     _             = script;
     _color        = color;
     _nwnxProfiler = nwnxProfiler;
 }
Пример #3
0
 public DurabilityService(
     INWScript script,
     IColorTokenService color,
     INWNXProfiler nwnxProfiler,
     INWNXCreature creature)
 {
     _             = script;
     _color        = color;
     _nwnxProfiler = nwnxProfiler;
     _creature     = creature;
 }
        public void DurabilityService_SetDurability_InvalidArguments_ShouldThrowException()
        {
            INWScript          script       = Substitute.For <INWScript>();
            IColorTokenService color        = Substitute.For <IColorTokenService>();
            INWNXProfiler      nwnxProfiler = Substitute.For <INWNXProfiler>();
            DurabilityService  service      = new DurabilityService(script, color, nwnxProfiler);

            Assert.Throws(typeof(ArgumentNullException), () =>
            {
                service.SetMaxDurability(null, 0.0f);
            });
        }
        public void DurabilityService_GetMaxDurability_ShouldReturnDefault()
        {
            INWScript          script       = Substitute.For <INWScript>();
            IColorTokenService color        = Substitute.For <IColorTokenService>();
            INWNXProfiler      nwnxProfiler = Substitute.For <INWNXProfiler>();
            DurabilityService  service      = new DurabilityService(script, color, nwnxProfiler);
            NWItem             item         = Substitute.For <NWItem>(script, service);

            item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD);

            float result = service.GetMaxDurability(item);

            Assert.AreEqual(30.0f, result);
        }
        public void DurabilityService_GetMaxDurability_InvalidType_ShouldReturnNegative1()
        {
            INWScript          script       = Substitute.For <INWScript>();
            IColorTokenService color        = Substitute.For <IColorTokenService>();
            INWNXProfiler      nwnxProfiler = Substitute.For <INWNXProfiler>();
            DurabilityService  service      = new DurabilityService(script, color, nwnxProfiler);
            NWItem             item         = Substitute.For <NWItem>(script, service);

            item.BaseItemType.Returns(x => NWScript.BASE_ITEM_BLANK_SCROLL);

            float result = service.GetMaxDurability(item);

            Assert.AreEqual(-1.0f, result);
        }
        public void DurabilityService_GetDurability_ShouldReturn6Point23()
        {
            INWScript          script       = Substitute.For <INWScript>();
            IColorTokenService color        = Substitute.For <IColorTokenService>();
            INWNXProfiler      nwnxProfiler = Substitute.For <INWNXProfiler>();
            DurabilityService  service      = new DurabilityService(script, color, nwnxProfiler);
            NWItem             item         = Substitute.For <NWItem>(script, service);

            item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD);
            item.GetLocalFloat(Arg.Any <string>()).Returns(6.23f);

            float result = service.GetDurability(item);

            Assert.AreEqual(6.23f, result);
        }
        public void DurabilityService_SetDurability_ShouldSetToSpecifiedValue()
        {
            INWScript          script       = Substitute.For <INWScript>();
            IColorTokenService color        = Substitute.For <IColorTokenService>();
            INWNXProfiler      nwnxProfiler = Substitute.For <INWNXProfiler>();
            DurabilityService  service      = new DurabilityService(script, color, nwnxProfiler);
            float  value = 0.0f;
            NWItem item  = Substitute.For <NWItem>(script, service);

            item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD);
            item.When(x => x.SetLocalFloat("DURABILITY_CURRENT", Arg.Any <float>()))
            .Do(x => value = x.ArgAt <float>(1));

            service.SetDurability(item, 12.52f);
            Assert.AreEqual(12.52f, value);
        }
        public void DurabilityService_SetDurability_InvalidType_ShouldNotRunOnce()
        {
            INWScript          script       = Substitute.For <INWScript>();
            IColorTokenService color        = Substitute.For <IColorTokenService>();
            INWNXProfiler      nwnxProfiler = Substitute.For <INWNXProfiler>();
            DurabilityService  service      = new DurabilityService(script, color, nwnxProfiler);
            bool   ranOnce = false;
            NWItem item    = Substitute.For <NWItem>(script, service);

            item.BaseItemType.Returns(x => NWScript.BASE_ITEM_BLANK_SCROLL);
            item.When(x => x.SetLocalFloat(Arg.Any <string>(), Arg.Any <float>()))
            .Do(x => ranOnce = true);

            service.SetDurability(item, 999.0f);
            Assert.AreEqual(false, ranOnce);
        }
        public void DurabilityService_SetMaxDurability_ShouldSetToDefaultValue()
        {
            INWScript          script       = Substitute.For <INWScript>();
            IColorTokenService color        = Substitute.For <IColorTokenService>();
            INWNXProfiler      nwnxProfiler = Substitute.For <INWNXProfiler>();
            DurabilityService  service      = new DurabilityService(script, color, nwnxProfiler);
            float  value = 0.0f;
            NWItem item  = Substitute.For <NWItem>(script, service);

            item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD);
            item.When(x => x.SetLocalFloat(Arg.Any <string>(), Arg.Any <float>()))
            .Do(x => value = x.ArgAt <float>(1));

            service.SetMaxDurability(item, -50.0f);
            Assert.AreEqual(30.0f, value);
        }
Пример #11
0
 public PerkService(INWScript script,
                    IColorTokenService color,
                    IDataService data,
                    IBiowareXP2 biowareXP2,
                    INWNXCreature nwnxCreature,
                    INWNXPlayerQuickBarSlot nwnxQBS,
                    INWNXPlayer nwnxPlayer,
                    INWNXProfiler nwnxProfiler)
 {
     _             = script;
     _color        = color;
     _data         = data;
     _biowareXP2   = biowareXP2;
     _nwnxCreature = nwnxCreature;
     _nwnxQBS      = nwnxQBS;
     _nwnxPlayer   = nwnxPlayer;
     _nwnxProfiler = nwnxProfiler;
 }
Пример #12
0
 public SkillService(
     INWScript script,
     IRandomService random,
     IBiowareXP2 biowareXP2,
     IEnmityService enmity,
     IPlayerStatService playerStat,
     IItemService item,
     IDataService data,
     AppCache cache,
     INWNXProfiler nwnxProfiler)
 {
     _             = script;
     _random       = random;
     _biowareXP2   = biowareXP2;
     _enmity       = enmity;
     _playerStat   = playerStat;
     _item         = item;
     _data         = data;
     _cache        = cache;
     _nwnxProfiler = nwnxProfiler;
 }
Пример #13
0
 public HelmetToggleService(IDataService data, INWScript script, INWNXProfiler nwnxProfiler)
 {
     _data         = data;
     _             = script;
     _nwnxProfiler = nwnxProfiler;
 }