Y2S1-Seabed_Explorer/test/strategy_pattern_tests/IndexOfRefractionTest.java
2020-06-07 22:14:52 +01:00

75 lines
2.4 KiB
Java

/*
* 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.IndexOfRefractionReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
/**
*
* @author Super
*/
public class IndexOfRefractionTest {
@Test
public void validAngleTest() {
ROV submersible = new ROV();
IndexOfRefraction equipment = new IndexOfRefraction(submersible, 30);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
System.out.println(current.getAngleOfRefraction());
assertTrue(current.getAngleOfRefraction() >= 0 && current.getAngleOfRefraction() <= 90);
}
}
@Test
public void validIndexTest() {
ROV submersible = new ROV();
IndexOfRefraction equipment = new IndexOfRefraction(submersible,30);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
System.out.println(current.getIndexOfRefraction());
assertTrue(current.getAngleOfRefraction() >= 0);
}
}
@Test
public void correctIndexTest() {
ROV submersible = new ROV();
IndexOfRefraction equipment = new IndexOfRefraction(submersible,30);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
System.out.println(current.getAngleOfRefraction() + " " + current.getIndexOfRefraction());
assertEquals(current.getIndexOfRefraction(), 30 / current.getAngleOfRefraction(),0);
}
}
}