Cook book written in Java
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

69 lines
1.3 KiB

package ksiazka.kucharska;
import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
import ksiazka.kucharska.CB_View;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import db.Cookbook;
import db.SearchRecipe;
import db.SearchRecipeAll;
public class SearchTest {
@BeforeClass
public static void addExamples()
{
File f1 = new File("cookbook.db");
File f2 = new File("cookbook-bkp.db");
if (f1.exists())
f1.renameTo(f2);
Cookbook myCb = new Cookbook();
CB_View theView = new CB_View();
RecipeManager rm = new RecipeManager();
rm.setRecipeBuilder(new ExampleRecipeBuilder(theView));
rm.constructRecipe();
CB_Model obj = rm.getRecipe();
myCb.insertRecipe(obj);
myCb.insertRecipe(obj);
myCb.closeConnection();
}
@Test
public void testSearch() {
CB_View theView = new CB_View();
Cookbook myCb = new Cookbook();
SearchRecipe sr;
sr = new SearchRecipeAll(theView);
List<String> names = sr.obtainRecipeNames();
myCb.closeConnection();
assertEquals(2, names.size());
}
@AfterClass
public static void delExamples()
{
Cookbook myCb = new Cookbook();
myCb.deleteRecipe("Kanapka");
myCb.closeConnection();
File f1 = new File("cookbook.db");
File f2 = new File("cookbook-bkp.db");
f1.delete();
if (f2.exists())
f2.renameTo(f1);
}
}