public void WhenInputIsEmptyWriteErrorMessage()
        {
            entity.HandleInput(new UserCommand());
            var data = ConsoleBufferHelper.GetText(proc.Output);

            data.ShouldBe("Please enter a name.");
        }
Пример #2
0
        public void Need_enough_tokens_to_repair()
        {
            gameState.Miner.InventoryItems.Add(new InventoryItem
            {
                Count = 10000,
                Item  = new GameItem
                {
                    Name = "Bolts"
                }
            });
            gameState.Miner.TaterTokens = 0;
            var command = new RepairCommand
            {
                GameState  = gameState,
                DiggerName = EXISTING_DIGGER_NAME,
            };

            repairCommandHandler.Handle(command);

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

            output[0].ShouldStartWith("Repairs will cost");
            output[1].ShouldBe("You don't have enough tokens.");
            output.Count().ShouldBe(2);
        }
Пример #3
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!");
        }
        public void With_enough_tokens_and_item_in_store_complete_purchase_with_pluralized_name_and_singular_name()
        {
            AddItemToStore();
            AddCountToItemInStore(2);

            var buyCount = 1;
            var command  = new BuyCommand
            {
                GameState  = gameState,
                NumOfItems = buyCount,
                ItemName   = GAME_ITEM_NAME_PLURALIZED
            };

            commandHandler.Handle(command);
            ConsoleBufferHelper.GetText(proc.Output);

            var commandSingle = new BuyCommand
            {
                GameState  = gameState,
                NumOfItems = buyCount,
                ItemName   = GAME_ITEM_NAME
            };

            commandHandler.Handle(commandSingle);

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

            gameState.Miner.InventoryItems.Count.ShouldBe(2);
            var inventoryItem = gameState.Miner.Inventory(GAME_ITEM_NAME);

            inventoryItem.Count.ShouldBe(2);
            output.ShouldBe($"{buyCount} {GAME_ITEM_NAME} have been added to your inventory");
        }
        public void WhenEntityHasAlreadySentMessageItShouldNotShowAgain()
        {
            entity.Update(Frame.NewFrame(TimeSpan.Zero, TimeSpan.Zero));
            string data = ConsoleBufferHelper.GetText(proc.Output);

            entity.Update(Frame.NewFrame(TimeSpan.Zero, TimeSpan.Zero));
            data = ConsoleBufferHelper.GetText(proc.Output);

            data.ShouldBeEmpty();
        }
        public void WhenEntityStartsDisplayHowdyMessageAndSetPromptToEnterName()
        {
            entity.Update(Frame.NewFrame(TimeSpan.Zero, TimeSpan.Zero));
            var data = ConsoleBufferHelper.GetLines(proc.Output);

            data[0].ShouldBe(@"Howdy pilgrim!  Welcome to glamorous world of 'tater chip mining!");
            data[1].ShouldBe("I'm Earl, your mine bot. I'll be you're right hand man ... 'er bot, around this here mining operation.");
            data[2].ShouldBe("Whats your name pilgrim?");

            data.Count.ShouldBe(3);
            gameState.PromptText.ShouldBe("Enter your name:");
        }
Пример #7
0
        public void Digger_with_name_has_to_exist()
        {
            var command = new RepairCommand
            {
                GameState  = gameState,
                DiggerName = MISSING_DIGGER_NAME,
            };

            repairCommandHandler.Handle(command);

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

            output.ShouldBe($"No digger named {MISSING_DIGGER_NAME} could be found.");
        }
        public void Digger_name_that_doesnt_exist_is_invalid()
        {
            var command = new EmptyCommand
            {
                GameState  = gameState,
                DiggerName = MISSING_DIGGER_NAME
            };

            commandHandler.Handle(command);

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

            output.ShouldBe($"Could not find digger named {MISSING_DIGGER_NAME}");
        }
        public void Shop_has_to_carry_the_item_to_complete_the_purchase()
        {
            var command = new BuyCommand
            {
                GameState  = gameState,
                NumOfItems = 2,
                ItemName   = GAME_ITEM_NAME
            };

            commandHandler.Handle(command);

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

            output.ShouldBe($"We do not carry {GAME_ITEM_NAME}.  Try MINER-MART.");
        }
Пример #10
0
        public void Need_enough_bolts_to_repair()
        {
            var command = new RepairCommand
            {
                GameState  = gameState,
                DiggerName = EXISTING_DIGGER_NAME,
            };

            repairCommandHandler.Handle(command);

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

            output[0].ShouldStartWith("Repairs will cost");
            output[1].ShouldBe("You don't have enough bolts.");
            output.Count().ShouldBe(2);
        }
Пример #11
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 ");
        }
Пример #12
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.");
        }
        public void Item_is_available_in_the_shop_to_complete_the_purchase()
        {
            AddItemToStore();

            var command = new BuyCommand
            {
                GameState  = gameState,
                NumOfItems = 1,
                ItemName   = GAME_ITEM_NAME
            };

            commandHandler.Handle(command);

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

            output.ShouldBe($"We do not currently have 1 of {GAME_ITEM_NAME} in stock.");
        }
        public void Buying_quantity_of_zero_or_less_should_fail()
        {
            AddItemToStore();

            var command = new BuyCommand
            {
                GameState  = gameState,
                NumOfItems = 0,
                ItemName   = GAME_ITEM_NAME
            };

            commandHandler.Handle(command);

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

            output.ShouldBe($"Invalid Quantity.");
        }
        public void With_enough_tokens_and_item_in_store_complete_purchase()
        {
            AddItemToStore();
            AddCountToItemInStore(1);

            var buyCount = 1;
            var command  = new BuyCommand
            {
                GameState  = gameState,
                NumOfItems = buyCount,
                ItemName   = GAME_ITEM_NAME
            };

            commandHandler.Handle(command);

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

            output.ShouldBe($"{buyCount} {GAME_ITEM_NAME} have been added to your inventory");
        }
        public void Miner_needs_enough_tater_tokens_to_complete_purchase()
        {
            AddItemToStore();
            AddCountToItemInStore(1);
            EmptyMinerTokens();

            var buyCount = 1;
            var command  = new BuyCommand
            {
                GameState  = gameState,
                NumOfItems = buyCount,
                ItemName   = GAME_ITEM_NAME
            };

            commandHandler.Handle(command);

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

            output.ShouldBe("You don't have enough tater tokens to make that purchase");
        }