Beispiel #1
0
        public static void VerifyTrack(this RoundDef def, ITrackOfCheckpoints track, string name, bool verifyTime = true)
        {
            var rating = track.Rating;

            for (var i = 0; i < def.Rating.Count; i++)
            {
                var expected = def.Rating[i];
                var actual   = rating[i];
                actual.RiderId.Should().Be(expected.RiderId,
                                           $"Place {i + 1} should have #{expected.RiderId}, but was #{actual.RiderId}" + name);
                actual.Started.Should().Be(expected.Started,
                                           $"#{actual.RiderId} should have Started={expected.Started}, but was {actual.Started}");
                actual.Finished.Should().Be(expected.Finished,
                                            $"#{actual.RiderId} should have Finished={expected.Finished}, but was {actual.Finished}");
                actual.LapCount.Should().Be(expected.LapCount,
                                            $"#{actual.RiderId} should have LapsCount={expected.LapCount}, but was {actual.LapCount}");
                if (verifyTime)
                {
                    actual.Start.Should().Be(def.RoundStartTime,
                                             $"#{actual.RiderId} should have Start={expected.Start}, but was {actual.Start}");

                    actual.Duration.Should().Be(expected.Duration,
                                                $"#{actual.RiderId} should have Duration={expected.Duration}, but was {actual.Duration}");
                }
            }
        }
        public static string ToRoundDefString(this ITrackOfCheckpoints track)
        {
            var sb = new StringBuilder();

            sb.Append($"Track");
            if (track.FinishCriteria.Duration > TimeSpan.Zero)
            {
                sb.Append($" {track.FinishCriteria.Duration.ToShortString()}");
            }
            sb.AppendLine(RoundDefParser.FormatCheckpoints(track.Checkpoints, track.RoundStartTime));
            sb.AppendLine("Rating");
            for (var i = 0; i < track.Rating.Count; i++)
            {
                var position = track.Rating[i];
                if (position.Finished)
                {
                    sb.Append("F");
                }
                sb.Append(position.RiderId);
                sb.Append($" {position.LapCount} ");
                sb.Append($"[{string.Join(" ", position.Laps.Select(l => l.AggDuration.ToShortString()))}]");
                if (track.Rating.Count - i > 1)
                {
                    sb.AppendLine();
                }
            }

            return(sb.ToString());
        }
Beispiel #3
0
 void Next(ITrackOfCheckpoints track)
 {
     track.Append(new Checkpoint(r.Next(1, 100).ToString(), new DateTime(timestamp += 10000)));
     var t = track.Rating;
 }