public void GetWeightsToNodeOnBreadthFirstSearch()
        {
            //Arrange
            IEnumerable <Rates> rates = MockRates.GetRates();
            Graph       ratesGraph    = rates.ToGraph();
            GraphSolver graphSolver   = new GraphSolver();

            //Act
            var ratesDict = graphSolver.GetWeightsToNodeOnBreadthFirstSearch(ratesGraph, "EUR");

            //Assert
            Assert.Empty(ratesDict["EUR"]);

            Assert.Single(ratesDict["USD"]);
            Assert.Equal(expected: (decimal)0.53, actual: ratesDict["USD"].ElementAt(0));

            Assert.Equal(expected: 2, actual: ratesDict["AUD"].Count());
            Assert.Equal(expected: (decimal)0.81, actual: ratesDict["AUD"].ElementAt(0));
            Assert.Equal(expected: (decimal)0.53, actual: ratesDict["AUD"].ElementAt(1));

            Assert.Equal(expected: 3, actual: ratesDict["CAD"].Count());
            Assert.Equal(expected: (decimal)1.41, actual: ratesDict["CAD"].ElementAt(0));
            Assert.Equal(expected: (decimal)0.81, actual: ratesDict["CAD"].ElementAt(1));
            Assert.Equal(expected: (decimal)0.53, actual: ratesDict["CAD"].ElementAt(2));
        }
        public void CalculateTotalRateRounding()
        {
            //Arrange
            IEnumerable <decimal> decimalRates  = MockRates.GetDecimalRates();
            AmountService         amountService = new AmountService();

            //Act
            var amount = amountService.CalculateTotalRateRounding((decimal)13.25, decimalRates, 2, MidpointRounding.ToEven);

            //Assert
            Assert.Equal(expected: (decimal)8.02, actual: amount);
        }
        public void ToGraph()
        {
            //Arrange
            IEnumerable <Rates> rates = MockRates.GetRates();

            //Act
            Graph ratesGraph = rates.ToGraph();

            //Assert
            Assert.Equal(expected: (decimal)1.89, actual: ratesGraph.Nodes["EUR"].GetWeight("USD"));
            Assert.Equal(expected: (decimal)0.53, actual: ratesGraph.Nodes["USD"].GetWeight("EUR"));
            Assert.Equal(expected: (decimal)0.81, actual: ratesGraph.Nodes["AUD"].GetWeight("USD"));
            Assert.Equal(expected: (decimal)1.23, actual: ratesGraph.Nodes["USD"].GetWeight("AUD"));
            Assert.Equal(expected: (decimal)0.71, actual: ratesGraph.Nodes["AUD"].GetWeight("CAD"));
            Assert.Equal(expected: (decimal)1.41, actual: ratesGraph.Nodes["CAD"].GetWeight("AUD"));
        }
        public void ExchangeToCurrency()
        {
            //Arrange
            GraphSolver   graphSolver   = new GraphSolver();
            AmountService amountService = new AmountService();
            TransactionBusinessService transactionBusinessService = new TransactionBusinessService(graphSolver, amountService, null);

            IEnumerable <Transactions> transactions = MockTransactions.GetTransactions();
            IEnumerable <Rates>        rates        = MockRates.GetRates();

            //Act
            var transactionsToCurrency = transactionBusinessService.ExchangeToCurrency(transactions, rates, "EUR");

            //Assert
            Assert.Equal(expected: (decimal)8.02, actual: transactionsToCurrency.ElementAt(0).Amount);
            Assert.Equal(expected: (decimal)5.26, actual: transactionsToCurrency.ElementAt(1).Amount);
            Assert.Equal(expected: (decimal)5.96, actual: transactionsToCurrency.ElementAt(2).Amount);
            Assert.Equal(expected: (decimal)10.25, actual: transactionsToCurrency.ElementAt(3).Amount);
        }