Ejemplo n.º 1
0
        /// <summary>
        /// Sets the built flinch action's success calculator factory.
        /// </summary>
        /// <param name="successCalculatorFactory">The built flinch action's success calculator factory.</param>
        public FlinchActionBuilder WithSuccessCalculatorFactory(ActionSuccessCalculatorFactory successCalculatorFactory)
        {
            if (successCalculatorFactory is null)
            {
                throw new ArgumentNullException(nameof(successCalculatorFactory));
            }

            _flinch.SuccessCalculatorFactory = successCalculatorFactory;
            _hasSuccessCalculatorFactory     = true;
            return(this);
        }
        private static FlinchAction CreateFlinchAction(
            IActionTargetCalculator actionTargetCalculator          = null,
            ActionSuccessCalculatorFactory successCalculatorFactory = null)
        {
            if (successCalculatorFactory is null)
            {
                successCalculatorFactory = () => new AlwaysActionSuccessCalculator();
            }

            var builder = new FlinchActionBuilder()
                          .WithActionTargetCalculator(actionTargetCalculator ?? Mock.Of <IActionTargetCalculator>())
                          .WithSuccessCalculatorFactory(successCalculatorFactory);

            return(builder.Build());
        }