public override void Run(out bool result)
 {
     result = true;
     // Test if items are seperated
     result &=
         AssertUtility.Expect(loadoutInstance.Count(), 2, string.Format(StringResource.ObjectCount, nameof(loadoutInstance)));
     // Test if CachedList is in sync
     result &=
         AssertUtility.Expect(loadoutInstance.CachedList.Count, 2, string.Format(StringResource.ObjectCount, nameof(loadoutInstance.CachedList)));
     // Test if the instance of the item is shared between source and loadout
     result &=
         AssertUtility.AreEqual(loadoutInstance.CachedList[0], loadoutInstance[loadoutInstance.CachedList[0]].Thing, nameof(loadoutInstance), nameof(loadoutInstance.CachedList));
     result &=
         AssertUtility.AreEqual(loadoutInstance.CachedList[1], loadoutInstance[loadoutInstance.CachedList[1]].Thing, nameof(loadoutInstance), nameof(loadoutInstance.CachedList));
     // Test if it stores the correct thing
     result &=
         AssertUtility.Expect(loadoutInstance.Contains(things[1]), true, string.Format(StringResource.ThingHas, nameof(loadoutInstance), things[1].LabelNoCount));
     result &=
         AssertUtility.Expect(loadoutInstance.Contains(things[2]), true, string.Format(StringResource.ThingHas, nameof(loadoutInstance), things[2].LabelNoCount));
     // Test whether the stackcount is correct
     result &=
         AssertUtility.Expect(loadoutInstance.CachedList[0].stackCount, 1, string.Format(StringResource.ObjectCount, things[1].LabelCapNoCount));
     result &=
         AssertUtility.Expect(loadoutInstance.CachedList[1].stackCount, 1, string.Format(StringResource.ObjectCount, things[2].LabelCapNoCount));
 }
        public override void Run(out bool result)
        {
            result    = true;
            _compRPGI = _pawn.GetComp <CompAwesomeInventoryLoadout>();

            _pawn.SetLoadout(_loadout4);
            foreach (AILoadout loadout in _list)
            {
                _pawn.SetLoadout(loadout);

                result &= AssertUtility.AreEqual(loadout, _compRPGI.Loadout, nameof(loadout), nameof(_compRPGI.Loadout));
                result &= AssertUtility.AreEqual(
                    _compRPGI.InventoryTracker.Count
                    , loadout.Count
                    , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker))
                    , string.Format(StringResource.ObjectCount, nameof(loadout)));
                foreach (Thing thing in loadout)
                {
                    result &= AssertUtility.Contains(
                        _compRPGI.InventoryTracker.Keys
                        , thing
                        , nameof(_compRPGI.InventoryTracker)
                        , thing.LabelCapNoCount);

                    result &= AssertUtility.Expect(
                        _compRPGI.InventoryTracker[thing]
                        , thing.stackCount * -1
                        , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker)));
                }
            }

            return;
        }
示例#3
0
        public override void Run(out bool result)
        {
            result = true;
            for (int i = 0; i < things.Count; i++)
            {
                List <Thing> thingsToRemove = things.Where(t => t != things[i]).ToList();
                foreach (Thing thing in thingsToRemove)
                {
                    loadoutInstance.Remove(thing);
                }

                result &=
                    // Check count
                    AssertUtility.Expect(loadoutInstance.Count, 1, string.Format(StringResource.ObjectCount, nameof(loadoutInstance)))
                    &&
                    AssertUtility.Expect(loadoutInstance.CachedList.Count, 1, string.Format(StringResource.ObjectCount, nameof(loadoutInstance.CachedList)))
                    &&     // Check integrity
                    AssertUtility.Contains(loadoutInstance, things[i], nameof(loadoutInstance), things[i].LabelCapNoCount)
                    &&     // Check reference equality
                    AssertUtility.AreEqual(loadoutInstance.CachedList[0], loadoutInstance[things[i]].Thing, nameof(loadoutInstance.CachedList), nameof(loadoutInstance));
                ;

                foreach (Thing thing in thingsToRemove)
                {
                    loadoutInstance.Add(thing);
                }
            }
        }
示例#4
0
 public override void Run(out bool result)
 {
     result  = true;
     result &=
         // Test if items are merged. Even it has a stack limit of 1, it doesn't matter in loadout
         AssertUtility.Expect(loadoutInstance.Count(), 1, string.Format(StringResource.ObjectCount, nameof(loadoutInstance)))
         // Test if CachedList is in sync
         &&
         AssertUtility.Expect(loadoutInstance.CachedList.Count, 1, string.Format(StringResource.ObjectCount, nameof(loadoutInstance.CachedList)))
         // Test if the instance of the item is shared between source and loadout
         &&
         AssertUtility.AreEqual(_toAdd, loadoutInstance[things[0]].Thing, nameof(_toAdd), nameof(loadoutInstance))
         &&
         AssertUtility.AreEqual(_toAdd, loadoutInstance.CachedList[0], nameof(_toAdd), nameof(loadoutInstance.CachedList))
         // Test whether the stackcount is correct
         &&
         AssertUtility.Expect(loadoutInstance.CachedList[0].stackCount, 2, string.Format(StringResource.ObjectCount, _toAdd.LabelCapNoCount));
 }
        public override void Run(out bool result)
        {
            CompAwesomeInventoryLoadout compRPGI = _pawn.GetComp <CompAwesomeInventoryLoadout>();

            result = true;

            foreach (AILoadout loadout in _loadouts)
            {
                _pawn.SetLoadout(loadout);
                result &= AssertUtility.AreEqual(loadout, compRPGI.Loadout, nameof(loadout), nameof(compRPGI.Loadout));
                if (loadout != null)
                {
                    result &= AssertUtility.AreEqual(
                        compRPGI.InventoryTracker.Count
                        , loadout.Count
                        , string.Format(StringResource.ObjectCount, nameof(compRPGI.InventoryTracker))
                        , string.Format(StringResource.ObjectCount, nameof(loadout)));
                    foreach (Thing thing in loadout)
                    {
                        result &= AssertUtility.Contains(
                            compRPGI.InventoryTracker.Keys
                            , thing
                            , nameof(compRPGI.InventoryTracker)
                            , thing.LabelCapNoCount);

                        result &= AssertUtility.Expect(
                            compRPGI.InventoryTracker[thing]
                            , thing.stackCount * -1
                            , string.Format(StringResource.ObjectCount, nameof(compRPGI.InventoryTracker)));
                    }
                }

                _pawn.outfits.CurrentOutfit = null;
                compRPGI.Loadout            = null;
                compRPGI.InventoryTracker   = null;
            }

            return;
        }
        public override void Run(out bool result)
        {
            result    = true;
            _compRPGI = _pawn.GetComp <CompAwesomeInventoryLoadout>();

            _pawn.SetLoadout(_loadout4);
            foreach (AILoadout loadout in _list)
            {
                _pawn.SetLoadout(loadout);

                result &= AssertUtility.AreEqual(loadout, _compRPGI.Loadout, nameof(loadout), nameof(_compRPGI.Loadout));
                result &= AssertUtility.AreEqual(
                    _compRPGI.InventoryTracker.Count
                    , loadout.Count
                    , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker))
                    , string.Format(StringResource.ObjectCount, nameof(loadout)));
                foreach (Thing thing in loadout)
                {
                    result &= AssertUtility.Contains(
                        _compRPGI.InventoryTracker.Keys
                        , thing
                        , nameof(_compRPGI.InventoryTracker)
                        , thing.LabelCapNoCount);

                    result &= AssertUtility.Expect(
                        _compRPGI.InventoryTracker[thing]
                        , LoadoutUtility.CompareThing(thing, _knifePlasteelLegendary)
                            ? (thing.stackCount - _knifePlasteelLegendary.stackCount) * -1
                            : LoadoutUtility.CompareThing(thing, _finemeal)
                                ? (thing.stackCount - _finemeal.stackCount) * -1
                                : thing.stackCount * -1
                        , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker)));

                    // Log.Warning(loadout.label + ": " + thing.LabelCapNoCount + ": " + _compRPGI.InventoryTracker[thing]);
                }
            }

            return;
        }
示例#7
0
        public override void Run(out bool result)
        {
            loadoutInstance.UpdateItem(_innerThing, QualityCategory.Awful);
            _innerThing.TryGetQuality(out QualityCategory qc);

            result =
                // Check count
                AssertUtility.Expect(loadoutInstance.Count, _count, string.Format(StringResource.ObjectCount, nameof(loadoutInstance)))
                && // Check if _innerThing is re-inserted
                AssertUtility.Contains(loadoutInstance, _innerThing, nameof(loadoutInstance), _innerThing.LabelCapNoCount)
                && // Check quality is set correctly
                AssertUtility.Expect(qc, QualityCategory.Awful, nameof(qc))
                && // Check quality setting is in sync
                AssertUtility.AreEqual(qc, loadoutInstance[_innerThing].AllowedQualityLevels.min, nameof(qc), typeof(QualityRange).Name);
            ;

            // Check integrity of the rest
            foreach (Thing thing in _thingsNotUpdated)
            {
                result &= AssertUtility.Contains(loadoutInstance, thing, nameof(loadoutInstance), thing.LabelCapNoCount);
            }
        }
        public override void Run(out bool result)
        {
            _compRPGI = _pawn.GetComp <CompAwesomeInventoryLoadout>();
            result    = true;

            for (int i = _loadouts.Count - 2; i > -1; i--)
            {
                AILoadout loadout = _loadouts[i];
                if (loadout != null)
                {
                    _pawn.SetLoadout(loadout);
                    // Check if they are the same instance
                    result &= AssertUtility.AreEqual(loadout, _compRPGI.Loadout, nameof(loadout), nameof(_compRPGI.Loadout));
                    // Check if InventoryTracker and Loadout has the same number of items
                    result &= AssertUtility.AreEqual(
                        _compRPGI.InventoryTracker.Count
                        , loadout.Count
                        , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker))
                        , string.Format(StringResource.ObjectCount, nameof(loadout)));
                    foreach (Thing thing in loadout)
                    {
                        // Check if InventoryTracker has same items as Loadout
                        result &= AssertUtility.Contains(
                            _compRPGI.InventoryTracker.Keys
                            , thing
                            , nameof(_compRPGI.InventoryTracker)
                            , thing.LabelCapNoCount);
                        // Check if stack count is matched
                        result &= AssertUtility.Expect(
                            _compRPGI.InventoryTracker[thing]
                            , thing.stackCount * -1
                            , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker)));
                    }
                }
            }
            return;
        }
示例#9
0
        public override void Run(out bool result)
        {
            result = true;

            // Test if items are merged. Even it has a stack limit of 1, it doesn't matter in loadout
            result &=
                AssertUtility.Expect(loadoutInstance.Count, 1, string.Format(StringResource.ObjectCount, nameof(loadoutInstance)));

            // Test if CachedList is in sync
            result &=
                AssertUtility.Expect(loadoutInstance.CachedList.Count, 1, string.Format(StringResource.ObjectCount, nameof(loadoutInstance.CachedList)));

            // Test if the instance of the item is shared between the dictionary and the cachedList
            result &=
                AssertUtility.AreEqual(loadoutInstance.CachedList[0], loadoutInstance[loadoutInstance.CachedList[0]].Thing, nameof(loadoutInstance.CachedList), nameof(loadoutInstance));

            // Test if it stores the correct thing
            result &=
                AssertUtility.Expect(loadoutInstance.Contains(things[3]), true, string.Format(StringResource.ThingHas, nameof(loadoutInstance), things[3].LabelNoCount));

            // Test whether the stackcount is correct
            result &=
                AssertUtility.Expect(loadoutInstance.CachedList[0].stackCount, things[3].stackCount * 2, string.Format(StringResource.ObjectCount, things[3].LabelCapNoCount));
        }