package convertCurrencies_test


import "testing"

import "seekia/internal/convertCurrencies"
import "seekia/internal/helpers"


func TestConvertCurrencies(t *testing.T){

	{
		ethereumWeiAmount := int64(1234567899876543210)

		etherAmount, err := convertCurrencies.ConvertCryptocurrencyAtomicUnitsToWholeUnits("Ethereum", ethereumWeiAmount)
		if (err != nil){
			t.Fatal("ConvertCryptocurrencyAtomicUnitsToWholeUnits failed: " + err.Error())
		}
		if (etherAmount != 1.23456789987654321){
			etherAmountString := helpers.ConvertFloat64ToString(etherAmount)
			t.Fatal("Unexpected Ether amount: " + etherAmountString)
		}
	}

	{
		ethereumWeiAmount := int64(123456)

		etherAmount, err := convertCurrencies.ConvertCryptocurrencyAtomicUnitsToWholeUnits("Ethereum", ethereumWeiAmount)
		if (err != nil){
			t.Fatal("ConvertCryptocurrencyAtomicUnitsToWholeUnits failed: " + err.Error())
		}
		if (etherAmount != 0.000000000000123456){
			etherAmountString := helpers.ConvertFloat64ToString(etherAmount)
			t.Fatal("Unexpected Ether amount: " + etherAmountString)
		}
	}

	{
		cardanoLovelaceAmount := int64(1234567)

		adaAmount, err := convertCurrencies.ConvertCryptocurrencyAtomicUnitsToWholeUnits("Cardano", cardanoLovelaceAmount)
		if (err != nil){
			t.Fatal("ConvertCryptocurrencyAtomicUnitsToWholeUnits failed: " + err.Error())
		}
		if (adaAmount != 1.2345670){
			adaAmountString := helpers.ConvertFloat64ToString(adaAmount)
			t.Fatal("Unexpected ADA amount: " + adaAmountString)
		}
	}

	{
		cardanoLovelaceAmount := int64(123456789987654321)

		adaAmount, err := convertCurrencies.ConvertCryptocurrencyAtomicUnitsToWholeUnits("Cardano", cardanoLovelaceAmount)
		if (err != nil){
			t.Fatal("ConvertCryptocurrencyAtomicUnitsToWholeUnits failed: " + err.Error())
		}
		if (adaAmount != 123456789987.6543274){
			adaAmountString := helpers.ConvertFloat64ToString(adaAmount)
			t.Fatal("Unexpected ADA amount: " + adaAmountString)
		}
	}	
}



