public void ShouldWin_WhenRandomValueNotGreaterThanWinProbability()
        {
            // arrange
            var options = new AttackOptions();

            var(originalPlayer, actualPlayer) = PlayerFixture.CreateClonedPlayers();
            var(mockCalculator, mockRandom)   = SetupRandomAndCalc(0.7, 0.7);

            var sut = CreateSut(
                player: actualPlayer,
                calculator: mockCalculator,
                random: mockRandom,
                options: options);
            // act
            var result = sut.Handle(new AttackCommand());

            // assert result
            result.Should().BeOfType <OkResult>();
            result.Message.Should().ContainEquivalentOf("win");
            // assert player state change
            actualPlayer.Health.Should()
            .Be(originalPlayer.Health - (int)(options.WinHealthReduceRate * originalPlayer.Health));
            actualPlayer.Coins.Should()
            .Be(originalPlayer.Coins + options.WinBonusCoins);
        }
        public void ShouldFail_WhenNotEnoughCoins()
        {
            // arrange
            var options = new TOptions();

            var(originalPlayer, actualPlayer) = PlayerFixture.CreateClonedPlayers(coins: 0);

            var sut = CreateSut(
                player: actualPlayer,
                options: options);

            // act
            var result = sut.Handle(new TCommand());

            // assert
            result.Should().BeOfType <ErrorResult>();
        }
        public void ShouldCallFormulaCalculator_WithFormulaFromOptions()
        {
            // arrange
            var(_, actualPlayer) = PlayerFixture.CreateClonedPlayers();
            var mockCalculator = Substitute.For <IFormulaCalculator>();
            var options        = new AttackOptions {
                WinProbFormula = "formula"
            };

            var sut = CreateSut(
                player: actualPlayer,
                calculator: mockCalculator,
                options: options);

            // act
            sut.Handle(new AttackCommand());
            // assert
            mockCalculator.Received().Calculate("formula", Arg.Any <FormulaContext>());
        }