SimpleValue extends AbstractSensorCommandValue { @Override protected float calculateValue() { int majorByte = getResultByteNumber(0); int minorByte = getResultByteNumber(1); return (majorByte * multiplier + minorByte) / divisor; } SimpleValue(CommandResult commandResult, float divisor);   SimpleValue(CommandResult commandResult, float multiplier, float divisor);   }
@Test public void testCalculateValue() throws Exception { int randomMultiplier = getRandomIntByte(); int randomDivisor = getRandomIntByte(); float expectedCalculatedValue = getExpectedCalculatedValue(randomMultiplier, randomDivisor); sut = new SimpleValue(commandResultMock, randomMultiplier, randomDivisor); float calculatedValue = sut.calculateValue(); assertThat(calculatedValue).isEqualTo(expectedCalculatedValue); }
@Test public void calculateValueShouldUseDefaultMultiplier() throws Exception { int defaultMultiplier = 255; int randomDivisor = getRandomIntByte(); float expectedCalculatedValue = getExpectedCalculatedValue(defaultMultiplier, randomDivisor); sut = new SimpleValue(commandResultMock, defaultMultiplier, randomDivisor); float calculatedValue = sut.calculateValue(); assertThat(calculatedValue).isEqualTo(expectedCalculatedValue); }