package pl.grzeslowski.jsupla.protocol.impl.decoders.sc;

import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;
import pl.grzeslowski.jsupla.protocol.api.structs.sc.SuplaRegisterClientResult;
import pl.grzeslowski.jsupla.protocol.impl.decoders.ProperDecoderTest;
import pl.grzeslowski.jsupla.protocol.impl.encoders.PrimitiveEncoderImpl;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static pl.grzeslowski.jsupla.protocol.common.RandomSupla.RANDOM_SUPLA;

@SuppressWarnings("WeakerAccess")
@RunWith(MockitoJUnitRunner.class)
public class SuplaRegisterClientResultDecoderImplTest extends ProperDecoderTest<SuplaRegisterClientResult> {
    @InjectMocks SuplaRegisterClientResultDecoderImpl decoder;
    private int resultCode;
    private int clientId;
    private int locationCount;
    private int chanelCount;
    private short activityTimeout;
    private short version;
    private short versionMin;

    @Override
    public SuplaRegisterClientResultDecoderImpl getDecoder() {
        return decoder;
    }

    @Override
    public int entitySize() {
        return SuplaRegisterClientResult.SIZE;
    }

    @SuppressWarnings("UnusedAssignment")
    @Override
    protected byte[] givenParseEntity(int offset) {
        final byte[] bytes = new byte[SuplaRegisterClientResult.SIZE + offset];

        resultCode = RANDOM_SUPLA.nextInt();
        offset += PrimitiveEncoderImpl.INSTANCE.writeInteger(resultCode, bytes, offset);

        clientId = RANDOM_SUPLA.nextPositiveInt();
        offset += PrimitiveEncoderImpl.INSTANCE.writeInteger(clientId, bytes, offset);

        locationCount = RANDOM_SUPLA.nextPositiveInt();
        offset += PrimitiveEncoderImpl.INSTANCE.writeInteger(locationCount, bytes, offset);

        chanelCount = RANDOM_SUPLA.nextPositiveInt();
        offset += PrimitiveEncoderImpl.INSTANCE.writeInteger(chanelCount, bytes, offset);

        activityTimeout = RANDOM_SUPLA.nextUnsignedByte();
        offset += PrimitiveEncoderImpl.INSTANCE.writeUnsignedByte(activityTimeout, bytes, offset);

        version = (short) (RANDOM_SUPLA.nextUnsignedByte() + 2);
        offset += PrimitiveEncoderImpl.INSTANCE.writeUnsignedByte(version, bytes, offset);

        versionMin = RANDOM_SUPLA.nextUnsignedByte(version);
        offset += PrimitiveEncoderImpl.INSTANCE.writeUnsignedByte(versionMin, bytes, offset);

        return bytes;
    }

    @Override
    protected void verifyParseEntity(final SuplaRegisterClientResult entity) {
        assertThat(entity.resultCode).isEqualTo(resultCode);
        assertThat(entity.clientId).isEqualTo(clientId);
        assertThat(entity.locationCount).isEqualTo(locationCount);
        assertThat(entity.channelCount).isEqualTo(chanelCount);
        assertThat(entity.activityTimeout).isEqualTo(activityTimeout);
        assertThat(entity.version).isEqualTo(version);
        assertThat(entity.versionMin).isEqualTo(versionMin);
    }
}
@@ -788,208 +788,104 @@
     
-private int resultCode;%0A    private int clientId;%0A    private int locationCount;%0A    private int chanelCount;%0A    private short activityTimeout;%0A    private short version;%0A    private short versionMin
+final SuplaRegisterClientResult proto = RANDOM_SUPLA.nextObject(SuplaRegisterClientResult.class)
 ;%0A%0A 
@@ -1282,53 +1282,8 @@
 %5D;%0A%0A
-        resultCode = RANDOM_SUPLA.nextInt();%0A
     
@@ -1339,16 +1339,22 @@
 Integer(
+proto.
 resultCo
@@ -1376,60 +1376,8 @@
 et);
-%0A%0A        clientId = RANDOM_SUPLA.nextPositiveInt();
 %0A   
@@ -1434,16 +1434,22 @@
 Integer(
+proto.
 clientId
@@ -1469,65 +1469,8 @@
 et);
-%0A%0A        locationCount = RANDOM_SUPLA.nextPositiveInt();
 %0A   
@@ -1527,16 +1527,22 @@
 Integer(
+proto.
 location
@@ -1567,63 +1567,8 @@
 et);
-%0A%0A        chanelCount = RANDOM_SUPLA.nextPositiveInt();
 %0A   
@@ -1625,20 +1625,27 @@
 Integer(
+proto.
 chan
+n
 elCount,
@@ -1664,68 +1664,8 @@
 et);
-%0A%0A        activityTimeout = RANDOM_SUPLA.nextUnsignedByte();
 %0A   
@@ -1727,16 +1727,22 @@
 nedByte(
+proto.
 activity
@@ -1769,74 +1769,8 @@
 et);
-%0A%0A        version = (short) (RANDOM_SUPLA.nextUnsignedByte() + 2);
 %0A   
@@ -1828,24 +1828,30 @@
 nsignedByte(
+proto.
 version, byt
@@ -1866,70 +1866,8 @@
 et);
-%0A%0A        versionMin = RANDOM_SUPLA.nextUnsignedByte(version);
 %0A   
@@ -1929,16 +1929,22 @@
 nedByte(
+proto.
 versionM
@@ -2134,16 +2134,22 @@
 EqualTo(
+proto.
 resultCo
@@ -2199,16 +2199,22 @@
 EqualTo(
+proto.
 clientId
@@ -2267,16 +2267,22 @@
 EqualTo(
+proto.
 location
@@ -2339,20 +2339,27 @@
 EqualTo(
+proto.
 chan
+n
 elCount)
@@ -2413,16 +2413,22 @@
 EqualTo(
+proto.
 activity
@@ -2478,24 +2478,30 @@
 ).isEqualTo(
+proto.
 version);%0A  
@@ -2546,16 +2546,22 @@
 EqualTo(
+proto.
 versionM

Use `RANDOM_SUPLA` to generate proto instance