public IEnumerable <LapDto> GetLapStream(long activityId, PeakStreamType streamType) { // string units = DisplayLabel.PeakStreamTypeUnits(streamType); var result = _context.ActivityPeakDetail .Where(p => p.ActivityId == activityId && p.StreamType == streamType && _context.PeakStreamTypeDuration .Where(d => d.PeakStreamType == p.StreamType) .Select(d => d.Duration) .ToList() .Contains(p.Duration) ) .OrderBy(p => p.Duration) .Select(p => new LapDto { Id = p.Id, Type = streamType, Selected = false, Name = p.Duration.ToString(), Value = p.Value.ToString(), StartIndex = p.StartIndex.Value, EndIndex = p.EndIndex.Value, StreamStep = p.Activity.StreamStep, SteppedStartIndex = p.StartIndex.Value / p.Activity.StreamStep, SteppedEndIndex = p.EndIndex.Value / p.Activity.StreamStep, }).ToList(); foreach (LapDto l in result) { l.Name = DisplayLabel.StreamDurationForDisplay(Convert.ToInt32(l.Name)); } return(result); }
public void DisplayLabel_DurationForDisplayTest() { Assert.AreEqual("Activity", DisplayLabel.StreamDurationForDisplay(int.MaxValue)); Assert.AreEqual("5 secs", DisplayLabel.StreamDurationForDisplay(5)); Assert.AreEqual("30 secs", DisplayLabel.StreamDurationForDisplay(30)); Assert.AreEqual("1 min", DisplayLabel.StreamDurationForDisplay(60)); Assert.AreEqual("1 min 1 secs", DisplayLabel.StreamDurationForDisplay(61)); Assert.AreEqual("2 min", DisplayLabel.StreamDurationForDisplay(120)); Assert.AreEqual("59 min", DisplayLabel.StreamDurationForDisplay(59 * 60)); Assert.AreEqual("59 min 59 secs", DisplayLabel.StreamDurationForDisplay((59 * 60) + 59)); Assert.AreEqual("01:00:00", DisplayLabel.StreamDurationForDisplay(60 * 60)); Assert.AreEqual("01:00:01", DisplayLabel.StreamDurationForDisplay((60 * 60) + 1)); }