public void if_transfers_are_valid_then_they_are_applied()
        {
            // Arrange
            var transferResult = new TransferActionsResult();
            _transferActionerMock.Setup(x => x.ApplyTransfers(_seasonState, _transferActions)).Returns(transferResult);

            // Act
            var result = _decisionActioner.ValidateAndApplyTransfers(_seasonState, _transferActions);

            // Assert
            Assert.That(result, Is.EqualTo(transferResult));
        }
        public TransferActionsResult ApplyTransfers(SeasonState seasonState, TransferActions transferActions)
        {
            var actionResults = new TransferActionsResult();

            if (VerboseLoggingEnabled)
            {
                _logger.Log(Tag.Transfers, string.Format("Applying gameweek {0} transfers", seasonState.Gameweek), true);
            }

            //set transferred in player cost
            foreach (var transfer in transferActions.Transfers)
            {
                seasonState.CurrentTeam = ProcessTransfer(transfer, seasonState.CurrentTeam);
            }

            seasonState.CurrentTeam.EnsureValidCaptains();

            actionResults.TotalTransfersMade = transferActions.Transfers.Count;

            actionResults.PenalisedTransfersMade = Math.Max(transferActions.Transfers.Count - seasonState.FreeTransfers, 0);
            seasonState.Money = CommonTransferFunctions.CalculateUpdatedTeamMoney(transferActions.Transfers, seasonState.Money);

            if (VerboseLoggingEnabled)
            {
                _logger.Log(Tag.Transfers, string.Format("Total transfers made: {0}", actionResults.TotalTransfersMade));
                _logger.Log(Tag.Transfers, string.Format("Penalised transfers made: {0}", actionResults.PenalisedTransfersMade));
                _logger.Log(Tag.Transfers, string.Format("Updated money: {0}", seasonState.Money.ToMoney()));
            }

            UpdateFreeTransfers(transferActions, seasonState);

            actionResults.UpdatedSeasonState = seasonState;

            actionResults = ApplyWildcards(seasonState, transferActions, actionResults);

            return actionResults;
        }
        private TransferActionsResult ApplyWildcards(SeasonState seasonState, TransferActions actions, TransferActionsResult result)
        {
            if (actions.PlayStandardWildcard)
            {
                if (VerboseLoggingEnabled)
                {
                    _logger.Log(Tag.Transfers, "Standard wildcard played", true);
                }
                seasonState.StandardWildCardPlayed = true;
                result.PenalisedTransfersMade = 0;
            }
            else if (actions.PlayTransferWindowWildcard)
            {
                if (VerboseLoggingEnabled)
                {
                    _logger.Log(Tag.Transfers, "Transfer window wildcard played", true);
                }
                seasonState.TransferWindowWildcardPlayed = true;
                result.PenalisedTransfersMade = 0;
            }

            return result;
        }
        private StrategyDecisionsResult ProcessStrategyDecisions(SeasonState seasonState, IStrategy strategy)
        {
            var updatedSeasonState = seasonState;

            var transferActions = new TransferActions();
            var transferResults = new TransferActionsResult();

            //no transfers in first gameweek
            if (seasonState.Gameweek > 1)
            {
                transferActions = strategy.MakeTransfers(updatedSeasonState);
                transferResults = _decisionActioner.ValidateAndApplyTransfers(updatedSeasonState, transferActions);
                updatedSeasonState = transferResults.UpdatedSeasonState;
            }

            var selectedTeamForGameweek = strategy.PickGameweekTeam(updatedSeasonState);
            updatedSeasonState = _decisionActioner.ValidateAndApplyGameweekTeamSelection(updatedSeasonState, selectedTeamForGameweek);

            return new StrategyDecisionsResult
                   {
                       TransfersMade = transferActions,
                       TransferResults = transferResults,
                       UpdatedSeasonState = updatedSeasonState
                   };
        }