void testAddAndRemoveNonGeneralCommand()
    {
        Command command;

        // Write and read about half of the ring buffer capacity
        int commandCount = ((COMMAND_BUFFER_SIZE / COMMAND_SIZE) / 2) + 1;

        for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
            addNonGeneralCommand(commandIndex % TEST_COMMANDS_SIZE);
            
        for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
        {
            int exampleCommandIndex = commandIndex % 4;
            buffer->GetCommand(command);
            CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][0]), command.Register());
            CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][1]), command.Action());
            CPPUNIT_ASSERT_EQUAL(testCommandParameters[exampleCommandIndex], command.Parameter());
        }

        // Write/read the same number of commands to test ring buffer wrap around
        for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
            addNonGeneralCommand(commandIndex % TEST_COMMANDS_SIZE);

        for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
        {
            int exampleCommandIndex = commandIndex % 4;
            buffer->GetCommand(command);
            CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][0]), command.Register());
            CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][1]), command.Action());
            CPPUNIT_ASSERT_EQUAL(testCommandParameters[exampleCommandIndex], command.Parameter());
        }
    }
    void testAddWhenCapacityExceeded()
    {
        Command command;

        buffer->AddCommandByte(0x00);

        // Exceed capacity
        for (int i = 0; i < (COMMAND_BUFFER_SIZE / COMMAND_SIZE); i++)
            for (int byteIndex = 0; byteIndex < COMMAND_SIZE; byteIndex++)
                buffer->AddCommandByte(0x00);

        buffer->AddCommandByte(0x00);

        // The buffer stores bytes comprising entire commands until its capacity is reached
        for (int i = 0; i < COMMAND_BUFFER_SIZE / COMMAND_SIZE; i++)
            buffer->GetCommand(command);
        
        // The buffer contains no elements now
        // It correctly buffers additional data
        addNonGeneralCommand(0);
        buffer->GetCommand(command);

        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[0][0]), command.Register());
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[0][1]), command.Action());
        CPPUNIT_ASSERT_EQUAL(testCommandParameters[0], command.Parameter());
    }
 void testAddStatusRegister()
 {
     Command command;
     
     buffer->AddCommandByte(MC_STATUS_REG);
     buffer->AddCommandByte(MC_RESET);
     
     buffer->GetCommand(command);
     CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(MC_GENERAL_REG), command.Register());
     CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(MC_RESET), command.Action());
     CPPUNIT_ASSERT_EQUAL(0, command.Parameter());
 }
    void testAddAndRemoveGeneralCommand()
    {
        Command command;

        for (uint8_t i = MC_GENERAL_LOW_FENCEPOST + 1; i < MC_GENERAL_HIGH_FENCEPOST; i++)
            buffer->AddCommandByte(i);
        
        for (uint8_t i = MC_GENERAL_LOW_FENCEPOST + 1; i < MC_GENERAL_HIGH_FENCEPOST; i++)
        {
            buffer->GetCommand(command);
            CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(MC_GENERAL_REG), command.Register());
            CPPUNIT_ASSERT_EQUAL(i, command.Action());
            CPPUNIT_ASSERT_EQUAL(0, command.Parameter());
        }
    }