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 ThrowException_WhenPassedDataContainsOnlyNumbers() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); string testName = "123"; //Act & Assert Assert.ThrowsException <Exception>(() => buyCommand.CommandName = testName); }
public void ThrowException_WhenPassedDataIsNull() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); string testName = null; //Act & Assert Assert.ThrowsException <ArgumentNullException>(() => buyCommand.CommandName = testName); }
public void ThrowException_WhenPassedDataIsTooLong() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); string testName = "TooLongStringggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"; //Act & Assert Assert.ThrowsException <Exception>(() => buyCommand.CommandName = testName); }
public void ThrowException_WhenInvalidDataIsPassed() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); int amount = 0; //Act & Assert Assert.ThrowsException <Exception>(() => buyCommand.Amount = amount); }
public CompositionManageViewModel(GameInfo gameInfo, Window window) { this.gameInfo = gameInfo; this.window = window; Compositions = gameInfo.compositions; QuantUp = new UpCommand(this); QuantDown = new DownCommand(this); Buy = new BuyCommand(this); Sale = new SaleCommand(this); }
public void ThrowException_WhenInvalidListIsPassed() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); Mock <IUser> userMock = new Mock <IUser>(); IList <string> input = new List <string>(); //Act & Assert Assert.ThrowsException <Exception>(() => buyCommand.Execute(input)); }
public void CorrectlyAssignValue_WhenValidDataIsPassed() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); string testName = "TestCommandName"; //Act buyCommand.CommandName = testName; //Assert Assert.AreEqual("TestCommandName", buyCommand.CommandName); }
public void CorrectlyAssignValue_WhenValidDataIsPassed() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); int amount = 10; //Act buyCommand.Amount = amount; //Assert Assert.AreEqual(amount, buyCommand.Amount); }
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."); }
public JsonResult Buy(IEnumerable <CoinViewModel> deposit, Guid goodsIdentity) { Contract.Requires(deposit != null); Contract.Requires(goodsIdentity != default(Guid)); var depositCoins = deposit .Select(x => new Coin(x.ParValue, x.Count)) .ToArray(); var goods = new GoodsIdentity(goodsIdentity); Contract.Assume(!goods.Equals(default(GoodsIdentity))); var command = new BuyCommand(depositCoins, goods); var @event = _buyCommandHandler.Execute(command); return(Json(@event)); }
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 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 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 TestShoes() { // Given IProduct shoes = new Shoes(); PurchaseController controller = new PurchaseController(); ICommand order = new OrderCommand(shoes); controller.InsertCommand(order); ICommand buy = new BuyCommand(shoes); controller.InsertCommand(buy); // When var order_t = order.Execute(); var buy_t = buy.Execute(); // Then Assert.AreEqual("Shoes", order_t); Assert.AreEqual("39.99", buy_t); }
public void CorrectlyExecute_WhenValidDataIsPassed() { //Arrange Mock <IBroker> brockerMock = new Mock <IBroker>(); Mock <IUser> userMock = new Mock <IUser>(); brockerMock.Setup(brocker => brocker.Buy("name", 10)).Returns("invoked"); BuyCommand buyCommand = new BuyCommand(brockerMock.Object); IList <string> input = new List <string>(); input.Add("name"); input.Add("10"); //Act string result = buyCommand.Execute(input); //Assert Assert.AreEqual("invoked", result); }
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"); }
public void TestTshirt() { // Given IProduct tshirt = new Tshirt(); PurchaseController controller = new PurchaseController(); ICommand order = new OrderCommand(tshirt); controller.InsertCommand(order); ICommand buy = new BuyCommand(tshirt); controller.InsertCommand(buy); // When var order_t = order.Execute(); var buy_t = buy.Execute(); // Then Assert.AreEqual("T-shirt", order_t); Assert.AreEqual("19.99", buy_t); }