Ver código fonte

AccountPanel update test

Tankernn 8 anos atrás
pai
commit
bf0000c9e4

+ 2 - 3
src/main/java/eu/tankernn/accounts/frame/MainFrame.java

@@ -36,7 +36,7 @@ public class MainFrame implements ListSelectionListener, DocumentListener {
 	private JList<Account> accounts;
 	private JScrollPane accountScrollPane;
 
-	private AccountPanel accountPanel;
+	public final AccountPanel accountPanel = new AccountPanel();;
 
 	/**
 	 * Launch the application.
@@ -86,8 +86,7 @@ public class MainFrame implements ListSelectionListener, DocumentListener {
 		accountScrollPane.setPreferredSize(new Dimension(100, 100));
 		listPanel.add(accountScrollPane, BorderLayout.CENTER);
 		frame.add(listPanel, BorderLayout.WEST);
-
-		accountPanel = new AccountPanel();
+		
 		frame.add(accountPanel, BorderLayout.EAST);
 
 		frame.setTitle("Account Management System");

+ 6 - 1
src/test/java/eu/tankernn/accounts/frame/test/MainFrameTest.java

@@ -2,11 +2,16 @@ package eu.tankernn.accounts.frame.test;
 
 import org.junit.Test;
 
+import eu.tankernn.accounts.Account;
+import eu.tankernn.accounts.AccountManager;
 import eu.tankernn.accounts.frame.MainFrame;
 
 public class MainFrameTest {
 	@Test
 	public void frameShouldInit() {
-		new MainFrame();
+		AccountManager.init(() -> {
+		}, false);
+		MainFrame f = new MainFrame();
+		f.accountPanel.updatePanel(new Account("Test", "Exampleman"));
 	}
 }

+ 11 - 0
src/test/java/eu/tankernn/accounts/test/AccountManagerTest.java

@@ -1,5 +1,8 @@
 package eu.tankernn.accounts.test;
 
+import java.io.File;
+
+import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -9,11 +12,14 @@ import eu.tankernn.accounts.AccountManager;
 
 public class AccountManagerTest {
 	static Account a;
+	static File f;
 
 	@BeforeClass
 	public static void setUpClass() {
 		AccountManager.init(() -> {
 		}, false);
+		AccountManager.setSaveWithEncryption(false);
+		f = new File("test.acc");
 		a = new Account("Test", "McExample");
 		AccountManager.addAccount(a);
 	}
@@ -25,4 +31,9 @@ public class AccountManagerTest {
 		Assert.assertTrue(AccountManager.search(a.lastName).contains(a));
 		Assert.assertEquals(a, AccountManager.getAccountByNumber(a.accountNumber).get());
 	}
+	
+	@AfterClass
+	public static void cleanUp() {
+		f.delete();
+	}
 }