done tests and fix some fucking bug!
This commit is contained in:
@@ -39,7 +39,7 @@ public class MenuBar extends JMenuBar {
|
||||
bookSearch.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new SearchDIalog("books");
|
||||
new SearchDIalog("books").setVisible(true);
|
||||
}
|
||||
});
|
||||
// 创建查询学生信息菜单项
|
||||
@@ -47,7 +47,7 @@ public class MenuBar extends JMenuBar {
|
||||
// 为查询学生信息菜单项添加事件监听器,当点击时弹出学生信息查询对话框
|
||||
studentSearch.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new SearchDIalog("students");
|
||||
new SearchDIalog("students").setVisible(true);
|
||||
}
|
||||
});
|
||||
// 创建查询借阅信息菜单项
|
||||
@@ -55,7 +55,7 @@ public class MenuBar extends JMenuBar {
|
||||
// 为查询借阅信息菜单项添加事件监听器,当点击时弹出借阅信息查询对话框
|
||||
rentSearch.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new SearchDIalog("rents");
|
||||
new SearchDIalog("rents").setVisible(true);
|
||||
}
|
||||
});
|
||||
// 将查询图书信息菜单项添加到查询菜单
|
||||
@@ -72,7 +72,7 @@ public class MenuBar extends JMenuBar {
|
||||
// 为添加图书信息菜单项添加事件监听器,当点击时弹出图书信息添加对话框
|
||||
bookAdd.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new BookAdder();
|
||||
new BookAdder().setVisible(true);
|
||||
}
|
||||
});
|
||||
// 创建添加学生信息菜单项
|
||||
|
||||
@@ -83,8 +83,6 @@ public class BookAdder extends JDialog {
|
||||
pack();
|
||||
// 设置对话框位置
|
||||
setLocation();
|
||||
// 设置对话框可见
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,8 +59,6 @@ public class SearchDIalog extends JDialog {
|
||||
pack();
|
||||
// 设置对话框位置
|
||||
setLocation();
|
||||
// 设置对话框可见
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package test
|
||||
|
||||
import com.msksbr.MainFrm.MenuItemDiaog.Adder.BookAdder
|
||||
import com.msksbr.MainFrm.MenuItemDiaog.SearchDIalog
|
||||
import com.msksbr.SQL.Connector
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertNotNull
|
||||
|
||||
class TestService {
|
||||
var connector: Connector? = null
|
||||
|
||||
@BeforeEach
|
||||
fun init() {
|
||||
connector = Connector()
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetBookMaxID() {
|
||||
val bookAdder = BookAdder()
|
||||
val max_id_from_ui = bookAdder.getBookMaxID()
|
||||
bookAdder.dispose()
|
||||
val rs = connector?.executeQuery("SELECT MAX(book_id) FROM books;")
|
||||
rs?.next()
|
||||
val max_id_from_sql = rs?.getInt(1)
|
||||
|
||||
assertNotNull(max_id_from_ui, "Get null value from function")
|
||||
assertEquals(max_id_from_ui, max_id_from_sql, "Not equals to the query from sql")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package test
|
||||
|
||||
import com.msksbr.MainFrm.MenuItemDiaog.Adder.BookAdder
|
||||
import com.msksbr.SQL.Connector
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertNotNull
|
||||
|
||||
class testUI {
|
||||
var connector: Connector? = null;
|
||||
|
||||
@BeforeEach
|
||||
fun init() {
|
||||
connector = Connector();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUIBeCenter() {
|
||||
val bookAdder = BookAdder();
|
||||
val location = bookAdder.location
|
||||
val size = bookAdder.size
|
||||
val screenSize = java.awt.Toolkit.getDefaultToolkit().screenSize
|
||||
|
||||
val expectedX = (screenSize.width - size.width) / 2
|
||||
val expectedY = (screenSize.height - size.height) / 2
|
||||
|
||||
assertNotNull(location,"location is null")
|
||||
assertEquals(expectedX, location.x, "x-coordinate is not be center")
|
||||
assertEquals(expectedY, location.y, "y-coordinate is not be center")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user