コード例 #1
0
        public void GetHashCode_WhenTwoDifferentInstancesAreCreated_ThenInstanceHashCodesAreNotEqual()
        {
            // arrange
            FlightPlanBuilder builder = FlightPlanBuilder.Create()
                                        .WithActualDepartureTime(1)
                                        .WithAircraft("B738")
                                        .WithAlternateAerodrome(new Aerodrome("LZKZ"))
                                        .WithCruisingLevel("320")
                                        .WithCruisingSpeed("250")
                                        .WithDepartureAerodrome(new Aerodrome("LZKZ"))
                                        .WithDepartureTime(2)
                                        .WithDestinationAerodrome(new Aerodrome("LZIB"))
                                        .WithEETHours(2)
                                        .WithEETMinutes(0)
                                        .WithEnduranceHours(5)
                                        .WithEnduranceMinutes(2)
                                        .WithFlightRules(FlightRules.IFR)
                                        .WithOtherInfo("NONE")
                                        .WithPersonsOnBoard(20)
                                        .WithRevision(22)
                                        .WithRoute("route")
                                        .WithSecondAlternateAerodrome(new Aerodrome("EPWA"))
                                        .WithTypeOfFlight(FlightType.GeneralAviation);

            FlightPlanBuilder builder1 = FlightPlanBuilder.Create()
                                         .WithActualDepartureTime(1)
                                         .WithAircraft("B738")
                                         .WithAlternateAerodrome(new Aerodrome("LZKZ"))
                                         .WithCruisingLevel("3230")
                                         .WithCruisingSpeed("2350")
                                         .WithDepartureAerodrome(new Aerodrome("LZKZ"))
                                         .WithDepartureTime(2)
                                         .WithDestinationAerodrome(new Aerodrome("LKPR"))
                                         .WithEETHours(2)
                                         .WithEETMinutes(0)
                                         .WithEnduranceHours(5)
                                         .WithEnduranceMinutes(2)
                                         .WithFlightRules(FlightRules.MVFR)
                                         .WithOtherInfo("N3ONE")
                                         .WithPersonsOnBoard(20)
                                         .WithRevision(22)
                                         .WithRoute("route")
                                         .WithSecondAlternateAerodrome(new Aerodrome("EPWA"))
                                         .WithTypeOfFlight(FlightType.GeneralAviation);

            FlightPlan instance0 = builder.Build();
            FlightPlan instance1 = builder1.Build();

            // act
            int result0 = instance0.GetHashCode();
            int result1 = instance1.GetHashCode();

            // assert
            Assert.That(instance0, Is.Not.Null);
            Assert.That(instance1, Is.Not.Null);
            Assert.That(ReferenceEquals(instance0, instance1), Is.Not.True);
            Assert.That(Equals(result0, result1), Is.False);
        }
コード例 #2
0
        public void Equals_WhenInstanceIsDeseraializeAndSerializedBack_ThenInstancesAreEqual()
        {
            // arrange
            FlightPlanBuilder builder = FlightPlanBuilder.Create()
                                        .WithActualDepartureTime(1)
                                        .WithAircraft("B738")
                                        .WithAlternateAerodrome(new Aerodrome("LZKZ"))
                                        .WithCruisingLevel("320")
                                        .WithCruisingSpeed("250")
                                        .WithDepartureAerodrome(new Aerodrome("LZKZ"))
                                        .WithDepartureTime(2)
                                        .WithDestinationAerodrome(new Aerodrome("LZIB"))
                                        .WithEETHours(2)
                                        .WithEETMinutes(0)
                                        .WithEnduranceHours(5)
                                        .WithEnduranceMinutes(2)
                                        .WithFlightRules(FlightRules.IFR)
                                        .WithOtherInfo("NONE")
                                        .WithPersonsOnBoard(20)
                                        .WithRevision(22)
                                        .WithRoute("route")
                                        .WithSecondAlternateAerodrome(new Aerodrome("EPWA"))
                                        .WithTypeOfFlight(FlightType.GeneralAviation);

            FlightPlan instance0 = builder.Build();

            string serializedText = instance0.Serialize();

            FlightPlan instance1 = serializedText.Deserialize <FlightPlan>();

            // act
            bool result = Equals(instance0, instance1);

            // assert
            Assert.That(instance0, Is.Not.Null);
            Assert.That(instance1, Is.Not.Null);
            Assert.That(ReferenceEquals(instance0, instance1), Is.Not.True);
            Assert.That(result, Is.True);
        }
コード例 #3
0
 public FlightPlan ExtractValue(string[] data)
 {
     return(FlightPlanBuilder.Create()
            .WithAircraft(data[ClientIndex.Pilot.FPL.Aircraft])
            .WithCruisingSpeed(data[ClientIndex.Pilot.FPL.CruisingSpeed])
            .WithDepartureAerodrome(new Aerodrome(data[ClientIndex.Pilot.FPL.DepartureAerodrome]))
            .WithCruisingLevel(data[ClientIndex.Pilot.FPL.CruisingLevel])
            .WithDestinationAerodrome(new Aerodrome(data[ClientIndex.Pilot.FPL.DestinationAerodrome]))
            .WithRevision(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.Revision]))
            .WithFlightRules(AnnotationExtensions.GetFromMap <FlightRules>(data[ClientIndex.Pilot.FPL.FlightRules]))
            .WithDepartureTime(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.DepartureTime]))
            .WithActualDepartureTime(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.ActualDepartureTime]))
            .WithEETHours(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.EET_Hours]))
            .WithEETMinutes(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.EET_Minutes]))
            .WithEnduranceHours(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.Endurance_Hours]))
            .WithEnduranceMinutes(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.Endurance_Minutes]))
            .WithAlternateAerodrome(new Aerodrome(data[ClientIndex.Pilot.FPL.AlternateAerodrome]))
            .WithOtherInfo(data[ClientIndex.Pilot.FPL.OtherInfo])
            .WithRoute(data[ClientIndex.Pilot.FPL.Route])
            .WithSecondAlternateAerodrome(new Aerodrome(data[ClientIndex.Pilot.FPL.SecondAlternateAerodrome]))
            .WithTypeOfFlight(AnnotationExtensions.GetFromMap <FlightType>(data[ClientIndex.Pilot.FPL.TypeOfFlight]))
            .WithPersonsOnBoard(_ivaoStringService.IVAO_GetInt(data[ClientIndex.Pilot.FPL.PersonsOnBoard]))
            .Build());
 }