UnitTests
parent
8975d33a1b
commit
feeb32f6fe
Binary file not shown.
|
@ -11,20 +11,20 @@ class KontoTest {
|
|||
Konto k = new Konto("Müller", 0);
|
||||
assertEquals("Müller", k.getInhaber());
|
||||
assertEquals(1000, k.getKontonummer());
|
||||
assertEquals(0, k.getKontostand());
|
||||
assertEquals(0, k.getKontostand());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testKontoEinUndAuszahlung() {
|
||||
Konto k = new Konto("Müller", 0);
|
||||
Konto k2 = new Konto("Mayer", 1);
|
||||
|
||||
|
||||
assertEquals("Mayer", k2.getInhaber());
|
||||
assertNotEquals(k.getKontonummer(), k2.getKontonummer());
|
||||
|
||||
|
||||
k2.einzahlen(100, "Test", "Einzahlung", "JUnit");
|
||||
assertEquals(100, k2.getKontostand());
|
||||
|
||||
|
||||
assertTrue(k2.auszahlen(50, "Test", "Auszahlung", "JUnit"));
|
||||
assertEquals(50, k2.getKontostand());
|
||||
|
||||
|
@ -32,4 +32,20 @@ class KontoTest {
|
|||
assertEquals(50, k2.getKontostand());
|
||||
}
|
||||
|
||||
@Test
|
||||
void dispoTest() {
|
||||
Girokonto ausgang = new Girokonto("Ausgang", 0);
|
||||
Girokonto ziel = new Girokonto("Ziel", 1);
|
||||
//Überweisung
|
||||
ausgang.überweise(ziel, 100, "Überweisung");
|
||||
assertEquals(-100, ausgang.getKontostand());
|
||||
assertEquals(100, ziel.getKontostand());
|
||||
|
||||
//Abheben
|
||||
ausgang.einzahlen(100, "Einzahlung", "ka", "ka");
|
||||
assertEquals(0, ausgang.getKontostand());
|
||||
ausgang.auszahlen(-100, "Auszahlung", "ka", "ka");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package de.hs_mannheim.informatik.bank.facade;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -16,4 +18,26 @@ class SystemTest {
|
|||
assertEquals("Testsystem", bs.getBankname());
|
||||
}
|
||||
|
||||
@Test
|
||||
void geldEinzahlen() throws Exception {
|
||||
Banksystem bs = new Banksystem("UnitBank");
|
||||
bs.kontoAnlegen("TestKonto", 1);
|
||||
assertEquals(0l, bs.getKontostand(1000));
|
||||
bs.geldEinzahlen(1000, 200l);
|
||||
assertEquals(200l, bs.getKontostand(1000));
|
||||
File x = new File(bs.getBankname() + "-bank-data.ser");
|
||||
assertTrue(x.delete());
|
||||
}
|
||||
|
||||
@Test
|
||||
void geldAuszahlen() throws Exception {
|
||||
Banksystem bs = new Banksystem("UnitBank");
|
||||
bs.kontoAnlegen("TestKonto", 1);
|
||||
bs.geldEinzahlen(1000, 200l);
|
||||
bs.geldAuszahlen(1000, 100l);
|
||||
assertEquals(100l, bs.getKontostand(1000));
|
||||
|
||||
File x = new File(bs.getBankname() + "-bank-data.ser");
|
||||
assertTrue(x.delete());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue