public void TestEquals()
        {
            var allCaps = new UnLocode("ABCDE");
            var mixedCase = new UnLocode("aBcDe");

            Assert.IsTrue(allCaps.Equals(mixedCase));
            Assert.IsTrue(mixedCase.Equals(allCaps));
            Assert.IsTrue(allCaps.Equals(allCaps));

            Assert.IsFalse(allCaps.Equals(null));
            Assert.IsFalse(allCaps.Equals(new UnLocode("FGHIJ")));
        }
示例#2
0
        public void testEquals()
        {
            UnLocode allCaps   = new UnLocode("ABCDE");
            UnLocode mixedCase = new UnLocode("aBcDe");

            Assert.IsTrue(allCaps.Equals(mixedCase));
            Assert.IsTrue(mixedCase.Equals(allCaps));
            Assert.IsTrue(allCaps.Equals(allCaps));

            Assert.IsFalse(allCaps.Equals(null));
            Assert.IsFalse(allCaps.Equals(new UnLocode("FGHIJ")));
        }
示例#3
0
        public override bool WillStopOverAt(ILocation location)
        {
            UnLocode locationCode = location.UnLocode;

            if (locationCode.Equals(Schedule[_movementIndex].DepartureLocation))
            {
                return(true);
            }
            for (int i = _movementIndex; i < Schedule.MovementsCount; ++i)
            {
                if (locationCode.Equals(Schedule[i].ArrivalLocation))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#4
0
        public override CargoState ClearCustoms(ILocation location, DateTime date)
        {
            if (!_lastKnownLocation.Equals(location.UnLocode))
            {
                string message = string.Format("The cargo is in port at {0}. Can not clear customs in {1}.", _lastKnownLocation, location.UnLocode);
                throw new ArgumentException(message, "location");
            }
            if (date < this._date)
            {
                string message = string.Format("The cargo arrived in port at {0}. Can not clear customs at {1}.", this._date, date);
                throw new ArgumentException(message, "date");
            }
            if (_customCleared)
            {
                throw new InvalidOperationException("Customs already cleared.");
            }

            return(new InPortCargo(this, date));
        }
 public virtual bool IsSatisfiedBy(IItinerary candidate)
 {
     if (null == candidate)
     {
         return(false);
     }
     if (!_origin.Equals(candidate.InitialDepartureLocation))
     {
         return(false);
     }
     if (!_destination.Equals(candidate.FinalArrivalLocation))
     {
         return(false);
     }
     if (_arrivalDeadline < candidate.FinalArrivalDate)
     {
         return(false);
     }
     return(true);
 }
示例#6
0
        public RouteSpecification(UnLocode origin, UnLocode destination, DateTime arrivalDeadline)
        {
            Origin = origin ?? throw new ArgumentNullException(nameof(origin));

            Destination = destination ?? throw new ArgumentNullException(nameof(destination));

            if (origin.Equals(destination))
            {
                throw new InvalidOperationException("Provided origin and destination are the same");
            }

            ArrivalDeadline = arrivalDeadline;
        }
示例#7
0
 public bool Equals(ICarrierMovement other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     return(_departureLocation.Equals(other.DepartureLocation) &&
            _arrivalLocation.Equals(other.ArrivalLocation) &&
            _arrivalTime.Equals(other.ArrivalTime) &&
            _departureTime.Equals(other.DepartureTime));
 }
示例#8
0
 public bool Equals(ILeg other)
 {
     if (null == other)
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     return(_voyage.Equals(other.Voyage) &&
            _loadLocation.Equals(other.LoadLocation) &&
            _unloadLocation.Equals(other.UnloadLocation) &&
            _loadTime.Equals(other.LoadTime) &&
            _unloadTime.Equals(other.UnloadTime));
 }