public void Test_FlightNumberToStringCasting()
        {
            // Arrange
            FlightNumber flightNumber = new FlightNumber("TK1957");

            // Act
            string flightNumberString = flightNumber;

            // Arrange
            Assert.Equal(flightNumber, flightNumberString);
            Assert.Equal(flightNumber.GetHashCode(), flightNumberString.GetHashCode());
            Assert.Equal(flightNumber.ToString(), flightNumberString);
            Assert.True(flightNumber.Equals(flightNumberString));
        }
        public void Test_StringToFlightNumberCasting()
        {
            // Arrrange
            string flightNumberString = "TK1706";

            // Act
            FlightNumber flightNumber = flightNumberString;

            // Assert
            Assert.Equal(flightNumberString, flightNumber);
            Assert.Equal(flightNumberString.GetHashCode(), flightNumber.GetHashCode());
            Assert.Equal(flightNumberString, flightNumber.ToString());
            Assert.True(flightNumber.Equals(flightNumberString));
        }
Exemple #3
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AirlineClass != null)
         {
             hashCode = hashCode * 59 + AirlineClass.GetHashCode();
         }
         if (ArrivalAirport != null)
         {
             hashCode = hashCode * 59 + ArrivalAirport.GetHashCode();
         }
         if (ArrivalTime != null)
         {
             hashCode = hashCode * 59 + ArrivalTime.GetHashCode();
         }
         if (CarrierCode != null)
         {
             hashCode = hashCode * 59 + CarrierCode.GetHashCode();
         }
         if (ConjunctionTicket != null)
         {
             hashCode = hashCode * 59 + ConjunctionTicket.GetHashCode();
         }
         if (CouponNumber != null)
         {
             hashCode = hashCode * 59 + CouponNumber.GetHashCode();
         }
         if (Date != null)
         {
             hashCode = hashCode * 59 + Date.GetHashCode();
         }
         if (DepartureTime != null)
         {
             hashCode = hashCode * 59 + DepartureTime.GetHashCode();
         }
         if (EndorsementOrRestriction != null)
         {
             hashCode = hashCode * 59 + EndorsementOrRestriction.GetHashCode();
         }
         if (ExchangeTicket != null)
         {
             hashCode = hashCode * 59 + ExchangeTicket.GetHashCode();
         }
         if (Fare != null)
         {
             hashCode = hashCode * 59 + Fare.GetHashCode();
         }
         if (FareBasis != null)
         {
             hashCode = hashCode * 59 + FareBasis.GetHashCode();
         }
         if (Fee != null)
         {
             hashCode = hashCode * 59 + Fee.GetHashCode();
         }
         if (FlightNumber != null)
         {
             hashCode = hashCode * 59 + FlightNumber.GetHashCode();
         }
         if (Number != null)
         {
             hashCode = hashCode * 59 + Number.GetHashCode();
         }
         if (OriginAirport != null)
         {
             hashCode = hashCode * 59 + OriginAirport.GetHashCode();
         }
         if (PassengerClass != null)
         {
             hashCode = hashCode * 59 + PassengerClass.GetHashCode();
         }
         if (ServiceClass != null)
         {
             hashCode = hashCode * 59 + ServiceClass.GetHashCode();
         }
         if (StopoverCode != null)
         {
             hashCode = hashCode * 59 + StopoverCode.GetHashCode();
         }
         if (Taxes != null)
         {
             hashCode = hashCode * 59 + Taxes.GetHashCode();
         }
         return(hashCode);
     }
 }