//-------------------------------------------------------------------------------------------------
//
// NMEA AIS Parser
/*********************************************************************************************
*
* Copyright (C) 2010 Ehud Pardo
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*********************************************************************************************/
//
//
// Ehud Pardo
//-------------------------------------------------------------------------------------------------
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AISNMEAParser;
namespace TestParser
{
///
/// Summary description for UnitTest1
///
[TestClass]
public class UnitTest1
{
public UnitTest1()
{
//
// TODO: Add constructor logic here
//
}
private TestContext testContextInstance;
///
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion
[TestMethod]
public void TestMethod1a()
{
AISNMEAParser.Parser parser = new Parser();
ParserErrorTypes errorNumber;
AISNMEAParser.Report report = parser.Parse("!AIVDM,1,1,,A,13u?etPv2;0n:dDPwUM1U1Cb069D,0*24", out errorNumber);
Assert.IsTrue(errorNumber == ParserErrorTypes.NoError);
Assert.IsTrue(((double)report.Params["Latitude"]).ToString("f6") == "57.660353");
Assert.IsTrue(((double)report.Params["Longitude"]).ToString("f6") == "11.832977");
Assert.IsTrue(report.MMSI == 265547250);
}
[TestMethod]
public void TestMethod1b()
{
AISNMEAParser.Parser parser = new Parser();
ParserErrorTypes errorNumber;
AISNMEAParser.Report report = parser.Parse("!AIVDM,1,1,,B,169E=e80198iMQBBu09utbV80<24,0*30", out errorNumber);
Assert.IsTrue(errorNumber == ParserErrorTypes.NoError);
Assert.IsTrue(((double)report.Params["Latitude"]).ToString("f6") == "33.123052");
Assert.IsTrue(((double)report.Params["Longitude"]).ToString("f6") == "122.653082");
Assert.IsTrue(report.MMSI == 412437940);
}
[TestMethod]
public void TestMethod3()
{
AISNMEAParser.Parser parser = new Parser();
ParserErrorTypes errorNumber;
AISNMEAParser.Report report = parser.Parse("!AIVDM,1,1,,,34eGJCh6ANhWAwwo862PaLELTBJ:V00000000S0D:R220,0*0B", out errorNumber);
Assert.IsTrue(errorNumber == ParserErrorTypes.NoError);
Assert.IsTrue(((double)report.Params["Latitude"]).ToString("f6") == "29.543695");
Assert.IsTrue(((double)report.Params["Longitude"]).ToString("f6") == "-88.810392");
Assert.IsTrue(((string)report.Params["Name"]) == "CAPT.J.RIMES");
Assert.IsTrue(((double)report.Params["Cog"]).ToString() == "335.9");
Assert.IsTrue(report.MMSI == 367059850);
}
[TestMethod]
public void TestMethod24()
{
AISNMEAParser.Parser parser = new Parser();
ParserErrorTypes errorNumber;
AISNMEAParser.Report report = parser.Parse("!AIVDM,1,1,,B,H5NHcTP<51@4TrM>10584@U