I need idea how to tests this class? I should test when Bufferedreader return other value than null? Or test when queue is empty?
public class DataFromTxtFile {
private Queue<String> myLines;
public DataFromTxtFile(){
this.myLines = new ArrayDeque<>();
}
public void readDataFromFile(File file) throws IOException {
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
myLines.offer(line);
}
}
}
public String getLine() {
if(myLines.size() == 0) return "";
return myLines.poll();
}
}
Aucun commentaire:
Enregistrer un commentaire