<?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 Nmea0183Mtw.php
  */
final class Nmea0183MtwTest extends PHPUnit_Framework_TestCase
{
	/**
	  * @dataProvider mtwProvider
	  */
	public function testMtw($sentence, $talker, $type, $temperature, $unit, $checksum, $valid)
	{
		$parser = new GnuBoat\Nmea\Parser(0);
		$sentence = $parser->parseSentence($sentence, "0183");
		$this->assertInstanceOf(GnuBoat\Nmea\Nmea0183\Nmea0183Mtw::class, $sentence);
		$this->assertEquals($talker, $sentence->talker());
		$this->assertEquals($type, $sentence->type());
		$this->assertEquals($temperature, $sentence->temperature());
		$this->assertEquals($unit, $sentence->unit());
		$this->assertEquals($checksum, $sentence->checksum());
		$message = "";
		$result = $sentence->valid($message);
		$this->assertEquals($valid, $result, $message);
	}
	
	public function mtwProvider()
	{
		return [
			"wrong_data_count" => ['$YXMTW,C*15', 'YX', 'MTW', 0, '', 15, false],
			"wrong_checksum" => ['$YXMTW,26.3,C*22', 'YX', 'MTW', 26.3, 'C', 22, false],
			"valid1" => ['$YXMTW,26.3,C*15', 'YX', 'MTW', 26.3, 'C', 15, true],
			"valid2" => ['!YXMTW,26.3,C*15', 'YX', 'MTW', 26.3, 'C', 15, true],
		];
	}
}

?>
