75 lines
2.2 KiB
Java
75 lines
2.2 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.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);
|
|
}
|
|
}
|
|
}
|