/*******************************************************************************
***  This file is part of Dux Rei Nummariae.                                 ***
***                                                                          ***
***  Copyright (C) 2017, 2018, 2019, 2020, 2021                              ***
***  John Schneiderman <Licensing _AT_ Schneiderman _DOT_ me>                ***
***                                                                          ***
***  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 <pecunia/Codes.h>
using pecunia::currency::Iso4217Codes;
#include <QTest>
// using QTEST_MAIN
#include <qt-mocks/Mock.hpp>
// using QMOCK_MEMBER_FUNCTION;

#include <conversion/CurrencySource.hpp>
using drn::conversion::CurrencySource;
#include <conversion/CurrencyConverter.h>
using drn::conversion::CurrencyConverter;
#include <foundation/Error.h>
using drn::foundation::Error;


namespace drn
{
namespace conversion
{
namespace tests
{

struct CurrencySourceTest : CurrencySource
{
	QMOCK_MEMBER_FUNCTION(double, fetch, const Iso4217Codes&, const Iso4217Codes&)
};

struct CurrencyConverterUT : QObject
{
	Q_OBJECT

	CurrencySourceTest source_;

private slots:
	//{ lookUp Tests

	void lookUp_SameCodes_ShouldBeOnePointZero()
	{
		const CurrencyConverter cc{this->source_};
		const double ratio{cc.lookUp(Iso4217Codes::USD, Iso4217Codes::USD)};
		QCOMPARE(ratio, 1.0);
	}
	void lookUp_UnknownFromCode_ShouldBeOnePointZero()
	{
		const CurrencyConverter cc{this->source_};
		const double ratio{cc.lookUp(Iso4217Codes::XXX, Iso4217Codes::USD)};
		QCOMPARE(ratio, 1.0);
	}
	void lookUp_UnknownToCode_ShouldBeOnePointZero()
	{
		const CurrencyConverter cc{this->source_};
		const double ratio{cc.lookUp(Iso4217Codes::USD, Iso4217Codes::XXX)};
		QCOMPARE(ratio, 1.0);
	}

	//}
};

}}}

QTEST_MAIN(drn::conversion::tests::CurrencyConverterUT)
#include "CurrencyConverter-unit-tests.moc"
