private void LoadContentsOfGpxFile(HttpPostedFileBase file, ImportViewModel importViewModel) { try { GpxTrack track = GpxEngine.GetGpxTrackFromFile(file); if (track != null) { ExerciseSession session = ExerciseSession.Create(track); _db.ExerciseSessions.AddOrUpdate(s => s.Name, session); _db.SaveChanges(); importViewModel.FilesImported++; } else { importViewModel.FilesFailed.Add(new FailedFile { Filename = file.FileName, ErrorMessage = "File could not be processed." }); } } catch (Exception e) { _log.Error(string.Format("Failed to import file {0} with message: {1}", file.FileName, e.Message)); importViewModel.FilesFailed.Add(new FailedFile { Filename = file.FileName, ErrorMessage = e.Message }); } }
public void ImportGpxFile_CorrectSessionDurationCalculated() { ExerciseSession sut = ExerciseSession.Create(_gpxTrack); Assert.That(sut, Is.Not.Null); Assert.That(sut.Duration, Is.EqualTo(new TimeSpan(0, 0, 23))); }
public void ImportGpxFile_CorrectSessionDistanceCalculated() { ExerciseSession sut = ExerciseSession.Create(_gpxTrack); Assert.That(sut, Is.Not.Null); Assert.That(sut.Distance, Is.EqualTo(0.12)); }
public void ImportGpxFile_MoreAccurateTrackElevationCalculated() { ExerciseSession sut = ExerciseSession.Create(_gpxTrack); //var sut = session.TrackSegments as List<TrackSegment>; Assert.That(sut, Is.Not.Null); Assert.That(sut.Elevation, Is.EqualTo(17)); }
public void ImportGpxFile_CorrectTrackElevationCalculated() { ExerciseSession sut = ExerciseSession.Create(_gpxTrack); //var sut = session.TrackSegments as List<TrackSegment>; Assert.That(sut, Is.Not.Null); Assert.That(sut.Elevation, Is.EqualTo(17).Within(0.1).Percent); }
public void ImportGpxFile_CorrectSegmentDistanceCalculated() { ExerciseSession session = ExerciseSession.Create(_gpxTrack); var sut = session.TrackSegments as List <TrackSegment>; Assert.That(sut, Is.Not.Null); Assert.That(sut.Count, Is.EqualTo(2)); Assert.That(sut[0].Distance, Is.EqualTo(0.0499477).Within(0.1).Percent); Assert.That(sut[1].Distance, Is.EqualTo(0.0708563).Within(0.1).Percent); }
public void ImportGpxFile_CorrectSegmentDurationCalculated() { ExerciseSession session = ExerciseSession.Create(_gpxTrack); var sut = session.TrackSegments as List <TrackSegment>; Assert.That(sut, Is.Not.Null); Assert.That(sut.Count, Is.EqualTo(2)); Assert.That(sut[0].Duration, Is.EqualTo(new DateTime(2009, 8, 24, 9, 9, 29).Subtract(new DateTime(2009, 8, 24, 9, 9, 19)))); Assert.That(sut[1].Duration, Is.EqualTo(new DateTime(2009, 8, 24, 9, 11, 43).Subtract(new DateTime(2009, 8, 24, 9, 11, 30)))); }
public void ImportGpxFile_CorrectSegmentElevationCalculated() { ExerciseSession session = ExerciseSession.Create(_gpxTrack); var sut = session.TrackSegments as List <TrackSegment>; Assert.That(sut, Is.Not.Null); Assert.That(sut.Count, Is.EqualTo(2)); Assert.That(sut[0].Elevation, Is.EqualTo(7)); Assert.That(sut[1].Elevation, Is.EqualTo(10).Within(0.1).Percent); }