public void DeleteTroopObject_WhenTroopObjectCreated_AddsUnitsBackToOriginalTroop( [Frozen] ITroopStub stub, [Frozen] ISimpleStub unitsToRetreat, StationedPartialTroopObjectInitializer troopInitializer) { unitsToRetreat.TotalCount.Returns <ushort>(1); stub.State.Returns(TroopState.Stationed); stub.RemoveFromFormation(FormationType.Defense, Arg.Any <ISimpleStub>()).Returns(true); stub.City.Troops.Remove(Arg.Any <ushort>()).Returns(true); var newStub = Substitute.For <ITroopStub>(); stub.City.CreateTroopStub().Returns(newStub); ITroopObject troopObject = Substitute.For <ITroopObject>(); troopObject.Stub.Returns(newStub); stub.City.CreateTroopObject(newStub, Arg.Any <uint>(), Arg.Any <uint>()).Returns(troopObject); troopInitializer.GetTroopObject(out troopObject); troopInitializer.DeleteTroopObject(); stub.Received(1).BeginUpdate(); stub.Received(1).AddAllToFormation(FormationType.Defense, newStub); stub.Received(1).EndUpdate(); }
public void DeleteTroopObject_WhenTroopObjectCreated_ScheduleRemovesTheTroopObject( [Frozen] ITroopStub stub, [Frozen] ISimpleStub unitsToRetreat, StationedPartialTroopObjectInitializer troopInitializer) { unitsToRetreat.TotalCount.Returns <ushort>(1); stub.State.Returns(TroopState.Stationed); stub.RemoveFromFormation(FormationType.Defense, Arg.Any <ISimpleStub>()).Returns(true); stub.City.Troops.Remove(Arg.Any <ushort>()).Returns(true); ITroopObject troopObject; troopInitializer.GetTroopObject(out troopObject); troopInitializer.DeleteTroopObject(); stub.City.Received(1).ScheduleRemove(troopObject, false); }
public void DeleteTroopObject_WhenTroopObjectFailsToRemoveFromCity_DoesNotAddUnitsBackToStub( [Frozen] ITroopStub stub, [Frozen] ISimpleStub unitsToRetreat, StationedPartialTroopObjectInitializer troopInitializer) { unitsToRetreat.TotalCount.Returns <ushort>(1); stub.State.Returns(TroopState.Stationed); stub.RemoveFromFormation(FormationType.Defense, Arg.Any <ISimpleStub>()).Returns(true); var newStub = Substitute.For <ITroopStub>(); newStub.TroopId.Returns <ushort>(5); stub.City.CreateTroopStub().Returns(newStub); stub.City.Troops.Remove(newStub.TroopId).Returns(false); ITroopObject troopObject; troopInitializer.GetTroopObject(out troopObject); troopInitializer.DeleteTroopObject(); stub.DidNotReceiveWithAnyArgs().AddAllToFormation(FormationType.Defense, null); }