package org.gphoto2;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import org.gphoto2.CameraList.CameraEntry;
import org.junit.Test;
public class CameraListTest {
@Test
public void test() {
CameraList list = new CameraList();
assertEquals(0, list.size());
list.add(new CameraEntry("Foo", "Bar"));
list.add(new CameraEntry("A", "B"));
list.add(new CameraEntry("X", "Z"));
assertEquals(3, list.size());
list.sort();
assertEquals("A", list.get(0).getName());
assertEquals("B", list.get(0).getValue());
assertEquals("Foo", list.get(1).getName());
assertEquals("Bar", list.get(1).getValue());
assertEquals("X", list.get(2).getName());
assertEquals("Z", list.get(2).getValue());
list.set(2, new CameraList.CameraEntry("Cata", "Ploft"));
assertEquals("Cata", list.get(2).getName());
assertEquals("Ploft", list.get(2).getValue());
list.clear();
assertEquals(0, list.size());
list.close();
}
@Test
public void testPopulate() {
CameraList list = new CameraList();
list.populate("meh %i", 2);
assertEquals(Arrays.asList(
new CameraEntry("meh 1", null),
new CameraEntry("meh 2", null)),
list);
list.close();
}
}