コード例 #1
0
        public void SetEquipment_ChangePistolByOtherPistol_EquipmentChanged()
        {
            // ARRANGE
            var pistolScheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Ranged, PropTags.Equipment.Weapon },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var pistol2Scheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Ranged, PropTags.Equipment.Weapon },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme();

            var pistol1 = new Equipment(pistolScheme, new[] { tacticalActScheme });
            var pistol2 = new Equipment(pistol2Scheme, new[] { tacticalActScheme });

            const int changedSlot = 0;

            var carrier = new EquipmentCarrier(slotSchemes);


            // ACT
            carrier[changedSlot] = pistol1;
            Action act = () =>
            {
                carrier[changedSlot] = pistol2;
            };



            // ASSERT
            act.Should().NotThrow();
        }
コード例 #2
0
        public void SetEquipment_DualShields_ExceptionRaised()
        {
            // ARRANGE
            var scheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Shield },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                },
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Range = new Range <int>(1, 6)
                }
            };

            var shieldEquipment1 = new Equipment(scheme, new[] { tacticalActScheme });
            var shieldEquipment2 = new Equipment(scheme, new[] { tacticalActScheme });

            const int shieldSlot1 = 0;
            const int shieldSlot2 = 1;

            var carrier = new EquipmentCarrier(slotSchemes);


            // ACT
            Action act = () =>
            {
                carrier[shieldSlot1] = shieldEquipment1;
                carrier[shieldSlot2] = shieldEquipment2;
            };


            // ASSERT
            act.Should().Throw <Exception>();
        }
コード例 #3
0
        public void SetEquipment_ChangeEquipment_EventRaised()
        {
            // ARRANGE
            var scheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme();

            var equipment = new Equipment(scheme, new[] { tacticalActScheme });

            const int changedSlot = 0;

            var carrier = new EquipmentCarrier(slotSchemes);


            // ACT
            using (var monitor = carrier.Monitor())
            {
                carrier[changedSlot] = equipment;



                // ASSERT
                monitor.Should().Raise(nameof(carrier.EquipmentChanged));
            }
        }
コード例 #4
0
        public void SetEquipment_PropCombinationInTwoSlots_ExpectedExceptionGeneration(string propSid1,
                                                                                       string propSid2,
                                                                                       bool expectException)
        {
            // ARRANGE

            for (var i = 0; i < 2; i++)
            {
                Equipment equipment1 = null;
                Equipment equipment2 = null;

                var scheme1 = GetSchemeBySid(propSid1);
                if (scheme1 != null)
                {
                    equipment1 = new Equipment(scheme1, new ITacticalActScheme[0]);
                }

                if (propSid1 == propSid2)
                {
                    if (scheme1 != null)
                    {
                        equipment2 = new Equipment(scheme1, new ITacticalActScheme[0]);
                    }
                }
                else
                {
                    var scheme2 = GetSchemeBySid(propSid2);

                    if (scheme2 != null)
                    {
                        equipment2 = new Equipment(scheme2, new ITacticalActScheme[0]);
                    }
                }

                var slotSchemes = new[] {
                    new PersonSlotSubScheme {
                        Types = EquipmentSlotTypes.Hand
                    },
                    new PersonSlotSubScheme {
                        Types = EquipmentSlotTypes.Hand
                    }
                };

                var slotIndex1 = i == 0 ? 0 : 1;
                var slotIndex2 = i == 0 ? 1 : 0;

                var carrier = new EquipmentCarrier(slotSchemes);


                // ACT
                Action act = () =>
                {
                    carrier[slotIndex1] = equipment1;
                    carrier[slotIndex2] = equipment2;
                };


                // ASSERT
                if (expectException)
                {
                    act.Should().Throw <Exception>();
                }
                else
                {
                    act.Should().NotThrow <Exception>();
                }
            }
        }
コード例 #5
0
        public void SetEquipment_PistolAndShield2_NoException()
        {
            // ARRANGE
            var pistolScheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Weapon, PropTags.Equipment.Ranged },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var shieldScheme = new TestPropScheme
            {
                Tags  = new[] { PropTags.Equipment.Shield },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Hand
                    }
                }
            };

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                },
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var tacticalActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Range = new Range <int>(1, 1)
                }
            };

            var pistolEquipment1 = new Equipment(pistolScheme, new[] { tacticalActScheme });
            var sheildEquipment2 = new Equipment(shieldScheme, new[] { tacticalActScheme });

            // Смена слотов относительно предыдузего теста
            const int swordSlot1 = 1;
            const int swordSlot2 = 0;

            var carrier = new EquipmentCarrier(slotSchemes);


            // ACT
            Action act = () =>
            {
                carrier[swordSlot1] = pistolEquipment1;
                carrier[swordSlot2] = sheildEquipment2;
            };


            // ASSERT
            act.Should().NotThrow <Exception>();
        }