Exemple #1
0
        public void TestMethod1()
        {
            List <int> listaOrigenes = new List <int> {
                0, 1, 2, 3
            };
            Nodo        n0         = new Nodo(0, 1, 20);
            Nodo        n1         = new Nodo(0, 3, 500);
            Nodo        n2         = new Nodo(0, 2, 200);
            Nodo        n3         = new Nodo(1, 2, 30);
            Nodo        n4         = new Nodo(1, 3, 30);
            List <Nodo> listaNodos = new List <Nodo>();

            listaNodos.Add(n0);
            listaNodos.Add(n1);
            listaNodos.Add(n2);
            listaNodos.Add(n3);
            listaNodos.Add(n4);
            Nodo        ns0           = new Nodo(0, 0, 0);
            Nodo        ns1           = new Nodo(0, 1, 20);
            Nodo        ns2           = new Nodo(1, 2, 50);
            Nodo        ns3           = new Nodo(1, 3, 50);
            List <Nodo> listaSolucion = new List <Nodo>();

            listaSolucion.Add(ns0);
            listaSolucion.Add(ns1);
            listaSolucion.Add(ns2);
            listaSolucion.Add(ns3);
            AlgoritmoD a1 = new AlgoritmoD();

            a1.setValores(0, 1, listaNodos, listaOrigenes);
            List <Nodo> l = a1.EjecutaAlgoritmo();

            l             = l.Select(x => x).OrderBy(x => x.IdOrigen).ToList();
            listaSolucion = listaSolucion.Select(x => x).OrderBy(x => x.IdOrigen).ToList();

            a1.setValores(0, 3, listaNodos, listaOrigenes);
            Nodo cE1 = new Nodo(0, 3, 500);

            List <Nodo> caminoEsperado = new List <Nodo>();

            caminoEsperado.Add(cE1);

            List <Nodo> caminoObtenido = a1.ObtenerCamino();

            Assert.Equal(caminoEsperado, caminoObtenido);
        }
Exemple #2
0
        public async void TestConversion()
        {
            var         transConversor = new TransConversor(new AlgoritmoD());
            AlgoritmoD  alg            = new AlgoritmoD();
            Transaction tranTest       = new Transaction();

            tranTest.Sku      = "1";
            tranTest.Amount   = "200";
            tranTest.Currency = "EUR";
            Transaction tranTest2 = new Transaction();

            tranTest2.Sku      = "1";
            tranTest2.Amount   = "100";
            tranTest2.Currency = "USD";
            Rates rate1 = new Rates();

            rate1.From = "EUR";
            rate1.To   = "EUR";
            rate1.Rate = "1";

            Rates rate2 = new Rates();

            rate2.From = "USD";
            rate2.To   = "EUR";
            rate2.Rate = "0.9";
            var listaRates = new List <Rates>();

            listaRates.Add(rate1);
            listaRates.Add(rate2);

            Transaction res1 = transConversor.Convertir(tranTest, listaRates);

            Assert.True(res1.Sku == "1");
            Assert.True(res1.Amount == "200");
            Assert.True(res1.Currency == "EUR");

            Transaction res2 = transConversor.Convertir(tranTest2, listaRates);

            Assert.True(res2.Sku == "1");
            Assert.True(res2.Amount == "90");
            Assert.True(res2.Currency == "EUR");
        }