Пример #1
0
        public CPilotRound Clone()
        {
            var clone = new CPilotRound();

            clone.Pilot          = Pilot.Clone();
            clone.TotalTime      = TotalTime;
            clone.BestLap        = BestLap;
            clone.LastLap        = LastLap;
            clone.ClearBestLap   = ClearBestLap;
            clone.ClearBestLapNo = ClearBestLapNo;
            clone.BestLapNo      = BestLapNo;
            clone.PenaltyCount   = PenaltyCount;
            clone.Laps           = new List <CLap>(Laps);
            return(clone);
        }
Пример #2
0
        public void Clone_WhenInstanceCloned_ThenInstancesHashCodesAreEqual()
        {
            // arrange
            PilotBuilder builder = PilotBuilder.Create()
                                   .WithAdministrativeVersion(AdministrativeRating.Observer)
                                   .WithCallsign("RYR2WQ")
                                   .WithClientRating(2)
                                   .WithConnectionTime(DateTime.Now)
                                   .WithFlightPlan(null)
                                   .WithFlightSimulator(FlightSimulator.Fly)
                                   .WithGroundSpeed(20)
                                   .WithHeading(222)
                                   .WithIsOnGround(true)
                                   .WithLocation(null)
                                   .WithName("name")
                                   .WithPlaneMTL("mtl")
                                   .WithProtocol("protocol")
                                   .WithRating(PilotRating.AirlineTransportPilot)
                                   .WithServer("server")
                                   .WithSoftwareName("sw name")
                                   .WithSoftwareVersion("1.2.3.4")
                                   .WithTransponderCode("7200")
                                   .WithVID("4321");

            Pilot instance0 = builder.Build();

            object instance1 = instance0.Clone();

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

            // assert
            Assert.That(instance0, Is.Not.Null);
            Assert.That(instance1, Is.Not.Null);
            Assert.That(instance1, Is.InstanceOf <Pilot>());
            Assert.That(ReferenceEquals(instance0, instance1), Is.Not.True);
            Assert.That(Equals(result0, result1), Is.True);
        }