示例#1
0
        public void GetInstantTrainCount_WhenEffectIsAssociateWithMultipleUnits([Frozen] IObjectTypeFactory objectTypeFactory,
                                                                                Formula formula,
                                                                                IStructure structure,
                                                                                ITroopStub troopStub)
        {
            var effects = new List <Effect>
            {
                new Effect
                {
                    Id        = EffectCode.UnitTrainInstantTime,
                    IsPrivate = false,
                    Location  = EffectLocation.City,
                    Value     = new object[] { 1, "BarrackUnits", 50, 50 }
                }
            };

            structure.City.Technologies.GetEffects(EffectCode.UnitTrainInstantTime).Returns(effects);
            objectTypeFactory.IsObjectType("BarrackUnits", 101).Returns(true);
            objectTypeFactory.IsObjectType("BarrackUnits", 102).Returns(true);
            objectTypeFactory.IsObjectType("BarrackUnits", 105).Returns(false);
            structure.Type.Returns((ushort)1);

            troopStub.ToUnitList().ReturnsForAnyArgs(new List <Unit>
            {
                new Unit(101, 10),
                new Unit(102, 25),
                new Unit(105, 10)
            });
            structure.City.Troops.MyStubs().Returns(new List <ITroopStub> {
                troopStub
            });

            formula.GetInstantTrainCount(structure).Should().Be(15);
        }