Beispiel #1
0
        public void When_listing_is_purchased_lease_purchase_should_complete()
        {
            var command = new BuyClaimCommand();

            command.GameState = gameState;
            command.Listings  = new ClaimListings();
            var claim      = MineClaim.Default;
            var claimPrice = 1;

            command.Listings.Add(new ClaimListing(claim, claimPrice, 2, SurveyResults.NoSurvey()));
            command.ListingId = command.Listings.GetAll().First().Id;

            var handler = new BuyClaimCommandHandler();

            handler.Handle(command);

            command.Listings.GetAll().Count.ShouldBe(0);
            gameState.Miner.TaterTokens.ShouldBe(MINER_TOKENS - claimPrice);
            gameState.Miner.ClaimLeases.GetAll().Count.ShouldBe(1);
            gameState.Miner.ClaimLeases.GetAll().First().Claim.ShouldBe(claim);

            var output = ConsoleBufferHelper.GetText(proc.Output);

            output.ShouldStartWith($"{1} Purchase Complete!");
        }
Beispiel #2
0
        public CommandsGroup Build()
        {
            var commandsGroup = new CommandsGroup
            {
                LocalCommands = new List <CommandsDefinition>()
                {
                    new CommandsDefinition
                    {
                        CommandText      = "buy",
                        EntryDescription = "buy [quantity] [item name] || buy [item name] (to buy single item)",
                        Description      = "Purchases the quantity indicated of the item requested.",
                        Command          = (userCommand, gameState) => {
                            var command = new BuyClaimCommand {
                                GameState = gameState, Listings = listings
                            };
                            if (userCommand.Parameters.Count == 0)
                            {
                                return(new FailedMessageCommand("Listing Id is required!"));
                            }

                            if (!int.TryParse(userCommand.Parameters[0], out int listingId))
                            {
                                return(new FailedMessageCommand("Listing Id is not a number!"));
                            }

                            command.ListingId = listingId;
                            return(command);
                        }
                    },
Beispiel #3
0
        public void Report_error_message_if_miner_does_not_have_enough_tokens()
        {
            var command = new BuyClaimCommand();

            command.GameState = gameState;
            command.Listings  = new ClaimListings();
            command.Listings.Add(new ClaimListing(MineClaim.Default, MINER_TOKENS + 1, 2, SurveyResults.NoSurvey()));
            command.ListingId = 1;

            var handler = new BuyClaimCommandHandler();

            handler.Handle(command);

            var output = ConsoleBufferHelper.GetText(proc.Output);

            output.ShouldStartWith($"You don't have enough tokens.  You need ");
        }
Beispiel #4
0
        public void Report_error_message_if_listing_id_does_not_exist()
        {
            var command = new BuyClaimCommand();

            command.GameState = gameState;
            command.Listings  = new ClaimListings();
            command.Listings.Add(new ClaimListing(MineClaim.Default, 1, 2, SurveyResults.NoSurvey()));
            command.ListingId = 2;

            var handler = new BuyClaimCommandHandler();

            handler.Handle(command);

            var output = ConsoleBufferHelper.GetText(proc.Output);

            output.ShouldBe($"Listing Id 2 is unavailable.");
        }