1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 
<?php
declare(strict_types=1);
namespace Test\IqrfAppModule\Model;
use App\IqrfAppModule\Model\OsParser;
use Nette\DI\Container;
use Tester\Assert;
use Tester\TestCase;
$container = require __DIR__ . '/../../bootstrap.php';
class OsParserTest extends TestCase {
    
    private $container;
    
    private $parser;
    
    private $packetOsInfo = '00.00.02.80.00.00.00.00.05.a4.00.81.38.24.79.08.00.28.00.f0';
    
    private $expectedOsInfo = [
        'ModuleId' => '8100A405',
        'OsVersion' => '3.08D',
        'TrType' => 'DCTR-72D',
        'McuType' => 'PIC16F1938',
        'OsBuild' => '7908',
        'Rssi' => -130,
        'SupplyVoltage' => '3.00 V',
        'Flags' => '00',
        'SlotLimits' => 'f0',
    ];
    
    public function __construct(Container $container) {
        $this->container = $container;
    }
    
    public function setUp() {
        $this->parser = new OsParser();
    }
    
    public function testParse() {
        $array = $this->parser->parse($this->packetOsInfo);
        Assert::equal($this->expectedOsInfo, $array);
    }
    
    public function testParseReadInfo() {
        $array = $this->parser->parseReadInfo($this->packetOsInfo);
        Assert::equal($this->expectedOsInfo, $array);
        $failPacket = preg_replace('/\.24\./', '\.ff\.', $this->packetOsInfo);
        $failArray = $this->parser->parseReadInfo($failPacket);
        $failExpected = $this->expectedOsInfo;
        $failExpected['TrType'] = $failExpected['McuType'] = 'UNKNOWN';
        Assert::equal($failExpected, $failArray);
    }
}
$test = new OsParserTest($container);
$test->run();