コード例 #1
0
        public void ShouldNotIncreaseHealthMoreThanMaxHealth_WhenPurchased()
        {
            var originalPlayer = PlayerFixture.CreateDefaultPlayer(maxHealth: 100, health: 95);

            var(actualPlayer, options) = MakePurchase(originalPlayer);

            actualPlayer.Health.Should()
            .Be(originalPlayer.MaxHealth);
            actualPlayer.Coins.Should()
            .Be(originalPlayer.Coins - options.Price);
        }
コード例 #2
0
        public void ShouldIncreasePower_WhenPurchase()
        {
            var originalPlayer = PlayerFixture.CreateDefaultPlayer();

            var(actualPlayer, options) = MakePurchase(originalPlayer);

            actualPlayer.Power.Should()
            .Be(originalPlayer.Power + options.MaxValue);
            actualPlayer.Coins.Should()
            .Be(originalPlayer.Coins - options.Price);
        }
コード例 #3
0
        private THandler CreateSut(
            Player player            = null,
            IPlayerStore playerStore = null,
            IRandom random           = null,
            TOptions options         = null)
        {
            player      = player ?? PlayerFixture.CreateDefaultPlayer();
            playerStore = playerStore ?? Substitute.For <IPlayerStore>();
            playerStore.GetPlayer().Returns(player);
            random = random ?? Substitute.For <IRandom>();
            var opts = Substitute.For <IOptions <TOptions> >();

            opts.Value.Returns(options ?? new TOptions());

            return(CreateSutImpl(playerStore, random, opts));
        }
コード例 #4
0
        private static AttackCommandHandler CreateSut(
            Player player                 = null,
            IPlayerStore playerStore      = null,
            IRandom random                = null,
            IFormulaCalculator calculator = null,
            AttackOptions options         = null)
        {
            player      = player ?? PlayerFixture.CreateDefaultPlayer();
            playerStore = playerStore ?? Substitute.For <IPlayerStore>();
            playerStore.GetPlayer().Returns(player);
            random     = random ?? Substitute.For <IRandom>();
            calculator = calculator ?? Substitute.For <IFormulaCalculator>();

            var optionsSnapshot = Substitute.For <IOptionsSnapshot <AttackOptions> >();

            optionsSnapshot.Value.Returns(options ?? new AttackOptions());

            return(new AttackCommandHandler(playerStore, random, calculator, optionsSnapshot));
        }