Y2S1-Seabed_Explorer/test/strategy_pattern_tests/SonarTest.java

76 lines
2.2 KiB
Java
Raw Permalink Normal View History

2020-06-07 21:14:52 +00:00
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.SonarReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.topographicalmapper.Sonar;
/**
*
* @author Super
*/
public class SonarTest {
@Test
public void validSonarTest() {
ROV submersible = new ROV();
Sonar equipment = new Sonar(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
SonarReading current = (SonarReading) data[i];
System.out.println(current.getReading());
assertTrue(current.getReading() >= 0 && current.getReading() <= 10000);
}
}
@Test
public void correctDepthTest() {
ROV submersible = new ROV();
Sonar equipment = new Sonar(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
SonarReading current = (SonarReading) data[i];
System.out.println(current.getReading() + " " + current.getDepth());
assertEquals(current.getDepth(), current.getReading() * 1.5, 0);
}
}
@Test
public void validDepthTest() {
ROV submersible = new ROV();
Sonar equipment = new Sonar(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
SonarReading current = (SonarReading) data[i];
System.out.println(current.getDepth());
assertTrue(current.getDepth() >= 0);
}
}
}