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 ClaimsOfficeRoom Build() { var greeting = new[] { "Welcome to the claims office.", "You can type [help] for a list of the store commands.", "To leave the office type exit." }; var listings = new ClaimListings(); var claim1 = _gameState.MineClaims.Add( new MineClaim( ChipDensity.Normal, SiteHardness.Hard )); var claim2 = _gameState.MineClaims.Add( new MineClaimFactory().BuildSite()); listings.Add(new ClaimListing(claim2, 10, 15, SurveyResults.NoSurvey())); listings.Add(new ClaimListing(claim1, 10, 15, SurveyResults.GetFromClaim(claim1))); var claimsOffice = new ClaimsOfficeRoom( _gameState, greeting, _baseCommandsGroup.Join(new ClaimsOfficeCommandsGroupFactory(listings).Build()), listings ); return(claimsOffice); }
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 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 "); }