public void CancelPurchase_When_PurchaseCanceled_Then_ReturnSuccess() { //Arrange var inventory = new List <ProductSlot>(); var purse = new List <CoinSlot>(); var vendingMachine = new VendingMachine(inventory, purse); var sut = new PurchaseProductUseCase(vendingMachine); //Act var actual = sut.CancelPurchase(); //Assert actual.HasFailed.Should().BeFalse(); }
public async Task ReceiveCancelPurchase() { var result = _useCase.CancelPurchase(); string message; if (result.CoinsReturned.Any()) { message = $"{result.Message} \r\n" + $"Coins to return: {string.Join(", ", result.CoinsReturned.Select(slot => $"{slot.Amount} x €{slot.Value}"))}"; } else { message = $"{result.Message} \r\n" + "Coins to return: None"; } await SendVendingMachineMessage(message); }
public void CancelPurchase_When_TenCentCoinAddedAndPurchaseCanceled_Then_ReturnSuccess() { //Arrange var coin = Coin.TwentyCents; var coinsReturned = new List <CoinSlot> { new CoinSlot(Coin.TwentyCents) }; var inventory = new List <ProductSlot>(); var purse = new List <CoinSlot>(); var vendingMachine = new VendingMachine(inventory, purse); var sut = new PurchaseProductUseCase(vendingMachine); //Act sut.InsertCoin(coin); var actual = sut.CancelPurchase(); //Assert actual.HasFailed.Should().BeFalse(); actual.CoinsReturned.Should().BeEquivalentTo(coinsReturned); }