public void RetreatUnits_RetreatsStationedUnitsThatAreNotInTribeThatOwnsStronghold( IStronghold stronghold, [FrozenMock] IActionFactory actionFactory, [FrozenMock] ITroopObjectInitializerFactory troopInitializerFactory, ITroopObjectInitializer troopInitializer, ITroopStub stub, ITribe tribe, ITribe shTribe, RetreatChainAction retreatAction, StrongholdManager strongholdManager) { stub.State.Returns(TroopState.Stationed); stub.City.Owner.IsInTribe.Returns(true); stub.City.Id.Returns<uint>(1234); stub.TroopId.Returns<ushort>(2); stub.City.Owner.Tribesman.Tribe.Returns(tribe); stronghold.MainBattle.Returns((IBattleManager)null); stronghold.Tribe.Returns(shTribe); stronghold.Troops.StationedHere().Returns(new[] { stub }); troopInitializerFactory.CreateStationedTroopObjectInitializer(stub).Returns(troopInitializer); actionFactory.CreateRetreatChainAction(stub.City.Id, troopInitializer).Returns(retreatAction); strongholdManager.RetreatUnits(stronghold); stub.City.Worker.Received(1).DoPassive(stub.City, retreatAction, true); }
public void RetreatUnits_WhenStubIsNotStationedState_ShouldNotRetreatUnits( IStronghold stronghold, [Frozen] IActionFactory actionFactory, ITroopStub stub, StrongholdManager strongholdManager) { stronghold.MainBattle.Returns((IBattleManager)null); stronghold.Troops.StationedHere().Returns(new[] { stub }); stub.State.Returns(TroopState.BattleStationed); stub.City.Owner.IsInTribe.Returns(false); strongholdManager.RetreatUnits(stronghold); stub.City.Worker.DidNotReceiveWithAnyArgs().DoPassive(null, null, false); }
public void UpdateGate_WhenNewMaxIsLower([FrozenMock] Formula formula, IStronghold stronghold, StrongholdManager strongholdManager) { formula.StrongholdGateLimit(0).ReturnsForAnyArgs(1000); stronghold.GateMax = 5000; stronghold.Gate = 5000; stronghold.MainBattle.Returns((IBattleManager)null); stronghold.GateBattle.Returns((IBattleManager)null); strongholdManager.UpdateGate(stronghold).Should().Be(Error.Ok); stronghold.Received(1).BeginUpdate(); stronghold.GateMax.Should().Be(1000); stronghold.GateMax.Should().Be(1000); }
public void UpdateGate_WhenReducedMaxAt50PercentHp([FrozenMock] Formula formula, IStronghold stronghold, StrongholdManager strongholdManager) { formula.StrongholdGateLimit(0).ReturnsForAnyArgs(1000); stronghold.GateMax = 5000; stronghold.Gate = 2500; stronghold.MainBattle.Returns((IBattleManager)null); stronghold.GateBattle.Returns((IBattleManager)null); strongholdManager.UpdateGate(stronghold).Should().Be(Error.Ok); stronghold.Gate.Should().Be(500); }
public void UpdateGate_WhenStrongholdInMainBattle(IBattleManager battleManager, IStronghold stronghold, StrongholdManager strongholdManager) { var initialGate = stronghold.GateMax = 1234; stronghold.MainBattle.Returns(battleManager); strongholdManager.UpdateGate(stronghold).Should().Be(Error.StrongholdNotUpdatableInBattle); stronghold.GateMax.Should().Be(initialGate); }