/*******************************************************************************
***  This file is part of _PROGRAM_.                                         ***
***                                                                          ***
***  Copyright (C) _YEARS_                                                   ***
***  <Business Name> <Licensing _AT_ WEBSITE>                                ***
***                                                                          ***
***  This program is free software: you can redistribute it and/or modify it ***
***  under the terms of the GNU Affero General Public License as published   ***
***  by the Free Software Foundation, either version 3 of the License, or    ***
***  (at your option) any later version.                                     ***
***                                                                          ***
***  This program is distributed in the hope that it will be useful, but     ***
***  WITHOUT ANY WARRANTY; without even the implied warranty of              ***
***  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                    ***
***  See the GNU Affero General Public License for more details.             ***
***                                                                          ***
***  You should have received a copy of the GNU Affero General Public License***
***  along with this program. If not, see <http://www.gnu.org/licenses/>.    ***
*******************************************************************************/
#include <QObject>
using ::QObject;
// using Q_OBJECT
#include <QTest>
// using QTEST_MAIN
// using QVERIFY_EXCEPTION_THROWN
#include <qt-mocks/Matchers.h>
using qt_mocks::equals;

#include <accounting/Account.h>
using drn::accounting::allAccountTypes;
#include <internal/TransactionPoster.h>
using drn::accounting::internal::EntryTypes;
using drn::accounting::internal::selectTAccount;


namespace drn
{
namespace accounting
{
namespace internal
{
namespace tests
{

struct SelectTAccountUT : QObject
{
	Q_OBJECT

private slots:
	void selectTAccount_AssetIncrease_ShouldBeDebit()
	{
		const auto actual{selectTAccount(AccountTypes::Asset, true)};
		QVERIFY_THAT(actual, equals(EntryTypes::Debit));
	}
	void selectTAccount_AssetDecrease_ShouldBeCredit()
	{
		const auto actual{selectTAccount(AccountTypes::Asset, false)};
		QVERIFY_THAT(actual, equals(EntryTypes::Credit));
	}
	void selectTAccount_LiabilityDecrease_ShouldBeDebit()
	{
		const auto actual{selectTAccount(AccountTypes::Liability, false)};
		QVERIFY_THAT(actual, equals(EntryTypes::Debit));
	}
	void selectTAccount_LiabilityIncrease_ShouldBeCredit()
	{
		const auto actual{selectTAccount(AccountTypes::Liability, true)};
		QVERIFY_THAT(actual, equals(EntryTypes::Credit));
	}
	void selectTAccount_RevenueDecrease_ShouldBeDebit()
	{
		const auto actual{selectTAccount(AccountTypes::Revenue, false)};
		QVERIFY_THAT(actual, equals(EntryTypes::Debit));
	}
	void selectTAccount_RevenueIncrease_ShouldBeCredit()
	{
		const auto actual{selectTAccount(AccountTypes::Revenue, true)};
		QVERIFY_THAT(actual, equals(EntryTypes::Credit));
	}
	void selectTAccount_ExpenseIncrease_ShouldBeDebit()
	{
		const auto actual{selectTAccount(AccountTypes::Expense, true)};
		QVERIFY_THAT(actual, equals(EntryTypes::Debit));
	}
	void selectTAccount_ExpenseDecrease_ShouldBeCredit()
	{
		const auto actual{selectTAccount(AccountTypes::Expense, false)};
		QVERIFY_THAT(actual, equals(EntryTypes::Credit));
	}
	void selectTAccount_CapitalDecrease_ShouldBeDebit()
	{
		const auto actual{selectTAccount(AccountTypes::Capital, false)};
		QVERIFY_THAT(actual, equals(EntryTypes::Debit));
	}
	void selectTAccount_CapitalIncrease_ShouldBeCredit()
	{
		const auto actual{selectTAccount(AccountTypes::Capital, true)};
		QVERIFY_THAT(actual, equals(EntryTypes::Credit));
	}
};

}}}}

QTEST_MAIN(drn::accounting::internal::tests::SelectTAccountUT)
#include "SelectTAccount-unit-tests.moc"
