public async Task HandleAsync_WithInvalidShoppingListId_ShouldThrowDomainException()
        {
            // Arrange
            var fixture = commonFixture.GetNewFixture();

            ShoppingListRepositoryMock shoppingListRepositoryMock = new ShoppingListRepositoryMock(fixture);

            var command = fixture.Create <FinishShoppingListCommand>();
            var handler = fixture.Create <FinishShoppingListCommandHandler>();

            shoppingListRepositoryMock.SetupFindByAsync(command.ShoppingListId, null);

            // Act
            Func <Task> function = async() => await handler.HandleAsync(command, default);

            // Assert
            using (new AssertionScope())
            {
                (await function.Should().ThrowAsync <DomainException>())
                .Where(e => e.Reason.ErrorCode == ErrorReasonCode.ShoppingListNotFound);
            }
        }
        public async Task HandleAsync_WithValidData_ShouldFinishShoppingList()
        {
            // Arrange
            var fixture = commonFixture.GetNewFixture();

            TransactionGeneratorMock   transactionGeneratorMock   = new TransactionGeneratorMock(fixture);
            ShoppingListRepositoryMock shoppingListRepositoryMock = new ShoppingListRepositoryMock(fixture);
            Mock <ITransaction>        transactionMock            = new Mock <ITransaction>();

            ShoppingListMock listMock          = shoppingListMockFixture.Create();
            ShoppingListMock remainingListMock = shoppingListMockFixture.Create();

            var command = fixture.Create <FinishShoppingListCommand>();
            var handler = fixture.Create <FinishShoppingListCommandHandler>();

            listMock.SetupFinish(command.CompletionDate, remainingListMock.Object);

            shoppingListRepositoryMock.SetupFindByAsync(command.ShoppingListId, listMock.Object);
            transactionGeneratorMock.SetupGenerateAsync(transactionMock.Object);

            // Act
            bool result = await handler.HandleAsync(command, default);

            // Assert
            using (new AssertionScope())
            {
                result.Should().BeTrue();
                listMock.VerifyFinishOnce(command.CompletionDate);
                transactionGeneratorMock.VerifyGenerateAsyncOnce();
                shoppingListRepositoryMock.VerifyStoreAsyncOnce(listMock.Object);
                shoppingListRepositoryMock.VerifyStoreAsyncOnce(remainingListMock.Object);
                transactionMock.Verify(
                    i => i.CommitAsync(
                        It.IsAny <CancellationToken>()),
                    Times.Once);
            }
        }