예제 #1
0
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.cajero = Cajero()
        billetes = []
        for i in range(0, 10):
            billetes.append(self.b1000)
        self.cajero.agregar_dinero(billetes)

    def test_contar(self):
        a = self.cajero.contar_dinero()
        self.assertEqual(a, "10 billetes de $1000, " +
                            "parcial $10000\n" +
                            "Total $10000")

    def test_extraer1(self):
        b = self.cajero.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_extraer2(self):
        c = self.cajero.extraer_dinero(12000)
        self.assertEqual(c, "Error. Quiere sacar mas dinero de lo que se puede"
                         )

    def test_extraer3(self):
        d = self.cajero.extraer_dinero(5520)
        self.assertEqual(d, "Error. El monto es incorrecto")
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.b500 = Billete500()
        self.cajero = Cajero()
        billetes = []
        for i in range(0, 10):
            billetes.append(self.b1000)
        for i in range(0, 20):
            billetes.append(self.b500)
        self.cajero.agregar_dinero(billetes)

    def test_contar(self):
        a = self.cajero.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" + "Total $20000")

    def test_extraer1(self):
        b = self.cajero.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_extraer2(self):
        c = self.cajero.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_extraer3(self):
        d = self.cajero.extraer_dinero(12100)
        self.assertEqual(
            d, "Error. No hay una combinacion de billetes que" +
            " nos permita extraer ese monto.")
예제 #3
0
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.b500 = Billete500()
        self.b200 = Billete200()
        self.cajero = Cajero()
        billetes = []
        for i in range(0, 10):
            billetes.append(self.b1000)
        for i in range(0, 20):
            billetes.append(self.b500)
        for i in range(0, 15):
            billetes.append(self.b200)
        self.cajero.agregar_dinero(billetes)

    def test_contar(self):
        a = self.cajero.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" +
            "15 billetes de $200, " + "parcial $3000\n" + "Total $23000")

    def test_extraer1(self):
        b = self.cajero.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_extraer2(self):
        c = self.cajero.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_extraer3(self):
        with self.assertRaises(CombinacionError):
            self.cajero.extraer_dinero(12100)

    def test_extraer5(self):
        with self.assertRaises(MontoError):
            self.cajero.extraer_dinero(-5000)

    def test_extraer6(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero.extraer_dinero(6850)

    def test_extraer7(self):
        with self.assertRaises(CantidadError):
            self.cajero.extraer_dinero(25000)

    def test_extraer13(self):
        c = self.cajero.extraer_dinero(23000)
        with self.assertRaises(CargaError):
            self.cajero.extraer_dinero(5000)
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.b500 = Billete500()
        self.b200 = Billete200()
        # Set 1
        self.cajero1 = Cajero()
        billetes1 = []
        for i in range(0, 10):
            billetes1.append(self.b1000)
        self.cajero1.agregar_dinero(billetes1)
        # Set 2
        self.cajero2 = Cajero()
        billetes2 = []
        for i in range(0, 10):
            billetes2.append(self.b1000)
        for i in range(0, 20):
            billetes2.append(self.b500)
        self.cajero2.agregar_dinero(billetes2)
        # Set 3
        self.cajero3 = Cajero()
        billetes3 = []
        for i in range(0, 10):
            billetes3.append(self.b1000)
        for i in range(0, 20):
            billetes3.append(self.b500)
        for i in range(0, 15):
            billetes3.append(self.b200)
        self.cajero3.agregar_dinero(billetes3)

# Test Set 1

    def test_set1_contar(self):
        a = self.cajero1.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" + "Total $10000")

    def test_set1_extraer1(self):
        b = self.cajero1.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_set1_extraer2(self):
        with self.assertRaises(CantidadError):
            self.cajero1.extraer_dinero(12000)

    def test_set1_extraer3(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero1.extraer_dinero(5520)

    def test_set1_extraer4(self):
        with self.assertRaises(MontoError):
            self.cajero1.extraer_dinero(-5000)

    def test_set1_extraer5(self):
        with self.assertRaises(CombinacionError):
            self.cajero1.extraer_dinero(9100)

    def test_set1_extraer6(self):
        c = self.cajero1.extraer_dinero(10000)
        with self.assertRaises(CargaError):
            self.cajero1.extraer_dinero(5000)

# Test Set 2

    def test_set2_contar(self):
        a = self.cajero2.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" + "Total $20000")

    def test_set2_extraer1(self):
        b = self.cajero2.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_set2_extraer2(self):
        c = self.cajero2.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_set2_extraer3(self):
        with self.assertRaises(CombinacionError):
            self.cajero2.extraer_dinero(12100)

    def test_set2_extraer4(self):
        with self.assertRaises(MontoError):
            self.cajero2.extraer_dinero(-5000)

    def test_set2_extraer5(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero2.extraer_dinero(6850)

    def test_set2_extraer6(self):
        with self.assertRaises(CantidadError):
            self.cajero2.extraer_dinero(25000)

    def test_set2_extraer7(self):
        c = self.cajero2.extraer_dinero(20000)
        with self.assertRaises(CargaError):
            self.cajero2.extraer_dinero(5000)


# Test Set 3

    def test_set3_contar(self):
        a = self.cajero3.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" +
            "15 billetes de $200, " + "parcial $3000\n" + "Total $23000")

    def test_set3_extraer1(self):
        b = self.cajero3.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_set3_extraer2(self):
        c = self.cajero3.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_set3_extraer3(self):
        with self.assertRaises(CombinacionError):
            self.cajero3.extraer_dinero(12100)

    def test_set3_extraer4(self):
        with self.assertRaises(MontoError):
            self.cajero3.extraer_dinero(-5000)

    def test_set3_extraer5(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero3.extraer_dinero(6850)

    def test_set3_extraer6(self):
        with self.assertRaises(CantidadError):
            self.cajero3.extraer_dinero(25000)

    def test_set3_extraer7(self):
        c = self.cajero3.extraer_dinero(23000)
        with self.assertRaises(CargaError):
            self.cajero3.extraer_dinero(5000)