Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }