Upload project.
This commit is contained in:
76
test/observer_pattern_tests/vessel/VesselTest.java
Normal file
76
test/observer_pattern_tests/vessel/VesselTest.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package observer_pattern_tests.vessel;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import seabedexplorer.observer.Observer;
|
||||
import seabedexplorer.submersible.AUV;
|
||||
import seabedexplorer.submersible.MS;
|
||||
import seabedexplorer.submersible.ROV;
|
||||
import seabedexplorer.submersible.Submersible;
|
||||
import seabedexplorer.util.submersible.SubmersibleUtil;
|
||||
import seabedexplorer.vessel.Vessel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cdrbv
|
||||
*/
|
||||
public class VesselTest {
|
||||
|
||||
public VesselTest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of attach method, of class Vessel.
|
||||
*/
|
||||
@Test
|
||||
public void testAttach() {
|
||||
System.out.println("attach");
|
||||
Observer AUV = new AUV();
|
||||
Observer ROV = new ROV();
|
||||
Observer MS = new MS();
|
||||
Vessel v = new Vessel();
|
||||
v.attach(AUV);
|
||||
v.attach(ROV);
|
||||
v.attach(MS);
|
||||
final int expectedValue = 3;
|
||||
assertEquals(expectedValue, v.getNoSubmersibles());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of detach method, of class Vessel.
|
||||
*/
|
||||
@Test
|
||||
public void testDetach() {
|
||||
System.out.println("detach");
|
||||
Vessel v = new Vessel();
|
||||
Observer AUV = new AUV();
|
||||
Observer ROV = new ROV();
|
||||
Observer MS = new MS();
|
||||
v.attach(AUV);
|
||||
v.attach(ROV);
|
||||
v.attach(MS);
|
||||
v.detach(AUV);
|
||||
v.detach(ROV);
|
||||
v.detach(MS);
|
||||
final int expectedValue = 0;
|
||||
assertEquals(expectedValue, v.getNoSubmersibles());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of updateObservers method, of class Vessel.
|
||||
*/
|
||||
@Test
|
||||
public void testUpdateObservers() {
|
||||
System.out.println("updateObservers");
|
||||
Vessel v = new Vessel();
|
||||
for(Submersible s: SubmersibleUtil.GenerateRandomSubmersibles(3))
|
||||
{
|
||||
v.attach(s);
|
||||
}
|
||||
boolean result = v.updateObservers("info");
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user