Y2S1-Seabed_Explorer/test/strategy_pattern_tests/ChemicalScannerTest.java

75 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.MaterialSample;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
/**
*
* @author Super
*/
public class ChemicalScannerTest {
@Test
public void validMassTest() {
ROV submersible = new ROV();
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass());
assertTrue(current.getMass() >= 0);
}
}
@Test
public void validDensityTest() {
ROV submersible = new ROV();
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getDensity());
assertTrue(current.getDensity() >= 0);
}
}
@Test
public void correctDensityTest() {
ROV submersible = new ROV();
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass() + " " + current.getDensity());
assertEquals(current.getMass(),current.getDensity() * 0.5, 0);
}
}
}