<?php
/*
    Copyright (C) 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//  enable in php 7
// declare(Strict_types=1);

/**
  * @brief Covers Nmea0183Dpt.php
  */
final class Nmea0183DptTest extends PHPUnit_Framework_TestCase
{
	/**
	  * @dataProvider dptProvider
	  */
	public function testDpt($sentence, $talker, $type, $depth, $offset, $checksum, $valid)
	{
		$parser = new GnuBoat\Nmea\Parser(0);
		$sentence = $parser->parseSentence($sentence, "0183");
		$this->assertInstanceOf(GnuBoat\Nmea\Nmea0183\Nmea0183Dpt::class, $sentence);
		$this->assertEquals($talker, $sentence->talker());
		$this->assertEquals($type, $sentence->type());
		$this->assertEquals($depth, $sentence->depth());
		$this->assertEquals($offset, $sentence->offset());
		$this->assertEquals($checksum, $sentence->checksum());
		$message = "";
		$result = $sentence->valid($message);
		$this->assertEquals($valid, $result, $message);
	}
	
	public function dptProvider()
	{
		return [
			"wrong_data_count" => ['$SDDPT,00.71,00.71,00.00*51', 'SD', 'dpt', 0, 0, 51, false],
			"wrong_checksum" => ['$SDDPT,00.71,00.00*22', 'SD', 'dpt', 0.71, 0.0, 22, false],
			"valid1" => ['$SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
			"valid2" => ['!SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
		];
	}
}

?>
