Esempio n. 1
0
        public async Task given_invalid_itemId_should_throw_an_exception()
        {
            var command = new StockItemStockDownCommand()
            {
                Id = Guid.NewGuid(), Amount = 1
            };
            var exception = await Record.ExceptionAsync(async() => await _handler.Handle(command, new CancellationToken()));

            exception.ShouldNotBeNull();
            exception.ShouldBeOfType <ItemNotFoundException>();
        }
Esempio n. 2
0
        public async Task given_valid_itemId_and_amount_should_succeed()
        {
            var id             = Guid.NewGuid();
            var amount         = 5;
            var amountToReduce = 1;
            var command        = new StockItemStockDownCommand()
            {
                Id = id, Amount = amountToReduce
            };
            var item = Item.Create(id, amount);

            _repository.GetAsync(command.Id).Returns(item);
            await _handler.Handle(command, new CancellationToken());

            await _repository.Received().UpdateAsync(item);

            await _eventProcessor.Received().ProcessAsync(item.Events);
        }