public void SuccessfulIsWithinFiftyMilesOfDuluthTest()
        {
            var shipPositionsInFiftyMiles = new[]
            {
                new Position("ShipA", 46.737640, -92.138895),
                new Position("ShipB", 46.775274, -91.946634),
                new Position("ShipC", 46.734346, -91.766733),
                new Position("ShipD", 46.771041, -92.097696),
                new Position("ShipE", 46.731052, -92.068857),
                new Position("ShipF", 46.771290, -92.080787),
                new Position("ShipG", 46.753887, -92.079929),
                new Position("ShipH", 46.739889, -92.134861),
                new Position("ShipI", 46.944402, -91.116686)
            };

            foreach (var position in shipPositionsInFiftyMiles)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsTrue(
                    shipTest.IsWithinFiftyMilesOfDuluth()
                    );
            }
        }
        public void StandardShipEtasFromStLouisBay()
        {
            Position testPosition = ShipPositions.StLouisBay;

            var ship = new ShipTest
            {
                Position            = testPosition,
                NavigationalStatus  = NavigationalStatus.Underway,
                CanalEntryTimestamp = DateTime.UtcNow.AddHours(-6),
                Speed = 1
            };

            var directDistanceToDuluth = GeoHelper.DistanceBetweenCoord(Ports.Duluth, testPosition);
            var shipSideDistance       = directDistanceToDuluth * Math.Sin(60d.ToRadians());
            var canalSideDistance      = directDistanceToDuluth * Math.Cos(60d.ToRadians());
            var totalDistance          = shipSideDistance + canalSideDistance;

            var expected = DateTime.UtcNow.AddHours(totalDistance / ship.Speed) + ShipTestProcessor.DataLag;

            ship.Update();

            // ReSharper disable once PossibleInvalidOperationException
            Assert.IsTrue(expected > ship.DerivedEta.Value.AddSeconds(-1));
            Assert.IsTrue(expected < ship.DerivedEta.Value.AddSeconds(1));
        }
        public void SuccessfulIsDestinationDuluthTest()
        {
            var shipTest = new ShipTest {
                Destination = Ports.Duluth
            };

            Assert.IsTrue(
                shipTest.IsDestinationDuluth()
                );
        }
        public void SuccessfulIsNotUnderwayTest()
        {
            var underway = new ShipTest {
                NavigationalStatus = NavigationalStatus.Other
            };

            Assert.IsFalse(
                underway.IsUnderway()
                );
        }
        public void SuccessfulIsUnderwayTest()
        {
            var underway = new ShipTest {
                NavigationalStatus = NavigationalStatus.Underway
            };

            Assert.IsTrue(
                underway.IsUnderway()
                );
        }
        public void SuccessfulIsDestinationNotDuluthTest()
        {
            var shipTest = new ShipTest {
                Destination = new Position("PortB", 46.706075, -92.016733)
            };

            Assert.IsFalse(
                shipTest.IsDestinationDuluth()
                );
        }
        public void ShipsNotUnderway()
        {
            var ship = new ShipTest
            {
                Position           = ShipPositions.FiftyMilesFromDuluthCanal,
                NavigationalStatus = NavigationalStatus.Other
            };

            ship.Update();

            Assert.IsNull(ship.DerivedEta);
        }
        public void ShipsRecentlyEnteringTheHarbor()
        {
            var ship = new ShipTest
            {
                Position            = ShipPositions.StLouisBay,
                NavigationalStatus  = NavigationalStatus.Underway,
                CanalEntryTimestamp = DateTime.UtcNow
            };

            ship.Update();

            Assert.IsNull(ship.DerivedEta);
        }
        public void NoCanalEntryTimestampForShipsNotInHarbor()
        {
            var ship = new ShipTest
            {
                Position            = ShipPositions.TwentyMilesFromDuluthCanal,
                NavigationalStatus  = NavigationalStatus.Other,
                CanalEntryTimestamp = DateTime.UtcNow
            };

            ship.Update();

            Assert.IsNull(ship.CanalEntryTimestamp);
        }
        public void ShipsInStLouisBayForAPeriodOfTime()
        {
            var ship = new ShipTest
            {
                Position            = ShipPositions.StLouisBay,
                NavigationalStatus  = NavigationalStatus.Underway,
                CanalEntryTimestamp = DateTime.UtcNow.AddHours(-6),
                Speed = 1
            };

            ship.Update();

            Assert.IsNotNull(ship.DerivedEta);
        }
        public void ShipsFarOutDeclaringDuluthButMovingOtherwise()
        {
            var ship = new ShipTest
            {
                Position           = ShipPositions.EastLakeSuperior,
                NavigationalStatus = NavigationalStatus.Underway,
                Destination        = Ports.Duluth,
                Heading            = 45
            };

            ship.Update();

            Assert.IsNull(ship.DerivedEta);
        }
        public void ShipsNearDuluthAndNotHeadingToDuluth()
        {
            var ship = new ShipTest
            {
                Position           = ShipPositions.FiftyMilesFromDuluthCanal,
                NavigationalStatus = NavigationalStatus.Underway,
                Destination        = Ports.Duluth,
                Heading            = 45
            };

            ship.Update();

            Assert.IsNull(ship.DerivedEta);
        }
        public void ShipsInHarborForAPeriodOfTimeNotHeadingToDuluth()
        {
            var ship = new ShipTest
            {
                Position            = ShipPositions.DuluthSuperiorDeadZone,
                NavigationalStatus  = NavigationalStatus.Underway,
                CanalEntryTimestamp = DateTime.UtcNow.AddHours(-6),
                Speed   = 1,
                Heading = 90
            };

            ship.Update();

            Assert.IsNull(ship.DerivedEta);
        }
        public void StationaryShipsInStLouisBay()
        {
            var testPosition = ShipPositions.StLouisBay;

            var ship = new ShipTest
            {
                Position            = testPosition,
                NavigationalStatus  = NavigationalStatus.Underway,
                CanalEntryTimestamp = DateTime.UtcNow.AddHours(-6),
                Speed = 0
            };

            ship.Update();

            Assert.AreEqual(DateTime.MaxValue, ship.DerivedEta);
        }
        public void StationaryShipsInStandardLocations()
        {
            var testPosition = ShipPositions.DuluthSuperiorDeadZone;

            var ship = new ShipTest
            {
                Position            = testPosition,
                NavigationalStatus  = NavigationalStatus.Underway,
                CanalEntryTimestamp = DateTime.UtcNow.AddHours(-6),
                Speed   = 0,
                Heading = 280
            };

            ship.Update();

            Assert.AreEqual(DateTime.MaxValue, ship.DerivedEta);
        }
        public void CanalEntryTimestampForShipsInHarbor()
        {
            var ship = new ShipTest
            {
                Position            = ShipPositions.StLouisBay,
                NavigationalStatus  = NavigationalStatus.Other,
                CanalEntryTimestamp = null
            };

            ship.Update();

            DateTime expected = DateTime.UtcNow.AddHours(ShipTestProcessor.CanalEntryTimestampOffset);

            // ReSharper disable once PossibleInvalidOperationException
            Assert.IsTrue(expected > ship.CanalEntryTimestamp.Value.AddSeconds(-1));
            Assert.IsTrue(expected < ship.CanalEntryTimestamp.Value.AddSeconds(1));
        }
        public void ShipsFarOutAndMovingToDuluth()
        {
            var testTime = DateTime.Now;

            var ship = new ShipTest
            {
                Position           = ShipPositions.EastLakeSuperior,
                NavigationalStatus = NavigationalStatus.Underway,
                Destination        = Ports.Duluth,
                Heading            = 200,
                Eta = testTime
            };

            ship.Update();

            Assert.AreEqual(testTime, ship.DerivedEta);
        }
        [TestMethod]//green
        public void SuccessfulIsNotInStLouisBay()
        {
            var shipPositionsNotInStLouisBay = new[]
            {
                new Position("ShipA", 46.757677, -92.000644)
            };

            foreach (var position in shipPositionsNotInStLouisBay)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsFalse(
                    shipTest.IsInStLouisBay()
                    );
            }
        }
        public void SuccessfulIsWithinFiftyMilesOfDuluthTest()
        {
            var shipPositionsInFiftyMiles = new[]
            {
                new Position("ShipA", 46.737640, -92.138895)
            };

            foreach (var position in shipPositionsInFiftyMiles)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsTrue(
                    shipTest.IsWithinFiftyMilesOfDuluth()
                    );
            }
        }
        public void SuccessfulIsNotInDuluthSuperiorHarbor()
        {
            var shipPositionsOutOfHarbor = new[]
            {
                new Position("ShipA", 46.944402, -91.116686),
                new Position("ShipB", 47.444500, -90.556929)
            };

            foreach (var position in shipPositionsOutOfHarbor)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsFalse(
                    shipTest.IsInDuluthSuperiorHarbor()
                    );
            }
        }
        public void SuccessfulIsInStLouisBay()
        {
            var shipPositionsInStLouisBay = new[]
            {
                new Position("ShipA", 46.754899, -92.121966),
                new Position("ShipB", 46.749253, -92.105229)
            };

            foreach (var position in shipPositionsInStLouisBay)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsTrue(
                    shipTest.IsInStLouisBay()
                    );
            }
        }
        [TestMethod]//green
        public void SuccessfulIsInStLouisBay()
        {
            var shipPositionsInStLouisBay = new[]
            {
                new Position("ShipA", 46.754899, -92.121966),
                new Position("ShipB", 46.750444, -92.114499),
                new Position("ShipC", 46.750326, -92.135227),
                new Position("ShipD", 46.763178, -92.094319)
            };

            foreach (var position in shipPositionsInStLouisBay)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsTrue(
                    shipTest.IsInStLouisBay()
                    );
            }
        }
        public void SuccessfulIsInDuluthSuperiorHarbor()
        {
            var shipPositionsInHarbor = new[]
            {
                new Position("ShipD", 46.771041, -92.097696),
                new Position("ShipE", 46.731052, -92.068857),
                new Position("ShipG", 46.753887, -92.079929),
                new Position("ShipH", 46.739889, -92.134861)
            };

            foreach (var position in shipPositionsInHarbor)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsTrue(
                    shipTest.IsInDuluthSuperiorHarbor()
                    );
            }
        }
        public void SuccessfulIsNotWithinFiftyMilesOfDuluthTest()
        {
            var shipPositionsWayOut = new[]
            {
                new Position("ShipA", 48.306980, -87.162673),
                new Position("ShipB", 47.807653, -86.569412),
                new Position("ShipC", 47.109425, -85.031326),
                new Position("ShipD", 47.120640, -87.755935),
                new Position("ShipE", 47.984439, -88.294265)
            };

            foreach (var position in shipPositionsWayOut)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsFalse(
                    shipTest.IsWithinFiftyMilesOfDuluth()
                    );
            }
        }
        public void SuccessfulIsNotInStLouisBay()
        {
            var shipPositionsOutOfHarbor = new[]
            {
                new Position("ShipA", 46.775274, -91.946634),
                new Position("ShipB", 46.734346, -91.766733),
                new Position("ShipC", 46.771290, -92.080787),
                new Position("ShipD", 46.944402, -91.116686),
                new Position("ShipE", 47.444500, -90.556929),
                new Position("ShipF", 46.692577, -92.004368)
            };

            foreach (var position in shipPositionsOutOfHarbor)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsFalse(
                    shipTest.IsInStLouisBay()
                    );
            }
        }
        public void ShipEtasFromStandardLocations()
        {
            var testPosition = ShipPositions.DuluthSuperiorDeadZone;

            var ship = new ShipTest
            {
                Position            = testPosition,
                NavigationalStatus  = NavigationalStatus.Underway,
                CanalEntryTimestamp = DateTime.UtcNow.AddHours(-6),
                Speed   = 1,
                Heading = 280
            };

            var directDistanceToDuluth = GeoHelper.DistanceBetweenCoord(Ports.Duluth, testPosition);

            var expected = DateTime.UtcNow.AddHours(directDistanceToDuluth / ship.Speed) + ShipTestProcessor.DataLag;

            ship.Update();

            // ReSharper disable once PossibleInvalidOperationException
            Assert.IsTrue(expected > ship.DerivedEta.Value.AddSeconds(-1));
            Assert.IsTrue(expected < ship.DerivedEta.Value.AddSeconds(1));
        }
        [TestMethod]//green
        public void SuccessfulIsNotInDuluthSuperiorHarbor()
        {
            var shipPositionsOutOfHarbor = new[]
            {
                new Position("ShipA", 46.737640, -92.138895),
                new Position("ShipB", 46.775274, -91.946634),
                new Position("ShipC", 46.734346, -91.766733),
                new Position("ShipF", 46.771290, -92.080787),
                new Position("ShipI", 46.944402, -91.116686),
                new Position("ShipJ", 47.444500, -90.556929)
            };

            foreach (var position in shipPositionsOutOfHarbor)
            {
                var shipTest = new ShipTest {
                    Position = position
                };

                Assert.IsFalse(
                    shipTest.IsInDuluthSuperiorHarbor()
                    );
            }
        }