public async Task TcxImport() { using (var input = await TestFileHelper.OpenForReadAsync(_fileName)) { var activity = new MemoryActivity(); var importer = new TcxImporter(activity); importer.Load(input); Assert.IsTrue(activity.TimeFrames.Count > 0); } }
/// <summary> /// Loads an <see cref="MemoryActivity"/> from a file /// </summary> /// <param name="fileName">Path of the file.</param> /// <param name="funcImporter">The importer to be created for loading the activity.</param> /// <returns>The imported <see cref="MemoryActivity"/>.</returns> protected async Task <MemoryActivity> LoadAsync(string fileName, Func <MemoryActivity, ActivityImporter> funcImporter) { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(fileName)) { var importer = funcImporter(activity); importer.Load(input); } return(activity); }
private async Task <MemoryActivity> LoadAsync(string fileName) { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(fileName)) { var importer = new FitImporter(activity); await importer.LoadAsync(input); } return(activity); }
public async Task TcxStripHeartRate() { using (var input = await TestFileHelper.OpenForReadAsync(_fileName)) { var stripper = new TcxStripper(); using (var output = await TestFileHelper.OpenForWriteAsync(GetStrippedFileName(_fileName, "_stripped_hr"))) { stripper.Strip(input, output, StripOptions.HeartRate); Assert.True(output.Length > 0); } } }
public async Task SmlImport() { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(_fileName)) { var importer = new SmlImporter(activity); await importer.LoadAsync(input); } Assert.True(activity.TimeFrames.Count > 0); Assert.AreEqual(70.263f, activity.Distance.GetValueAs(DistanceUnit.Kilometer), 0.1f); }
public async Task Recode() { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(GetFileName("2015-10-31-100331.fit"))) { var importer = new FitImporter(activity); importer.Load(input); } var activityRepaired = activity.Repair(); Assert.AreEqual(26.092411, activityRepaired.AvgSpeed.GetValueAs(SpeedUnit.KilometerPerHour), 0.05); }
private async Task <MemoryActivity> Import(string fileName) { using (var input = await TestFileHelper.OpenForReadAsync(fileName)) { var activity = new MemoryActivity(); var importer = new GpxImporter(activity); importer.Load(input); //var exporter = new FitExporter(activity); //using (var output = await TestFileHelper.OpenForWriteAsync(_fileName + ".fit")) //{ // exporter.Save(output); //} return(activity); } }
public async Task TcxCopy() { using (var input = await TestFileHelper.OpenForReadAsync(_fileName)) { var stripper = new TcxStripper(); using (var output = await TestFileHelper.OpenForWriteAsync(GetStrippedFileName(_fileName))) { stripper.Strip(input, output, StripOptions.None); output.Seek(0, SeekOrigin.Begin); var doc = XElement.Load(output); Assert.IsTrue(doc.Nodes().Any()); } } }
public async Task Import() { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(Test2FileName)) { var importer = new FitImporter(activity); importer.MessageBroadcaster.SessionMesgEvent += (sender, args) => { var msg = args.mesg as SessionMesg; var summary = msg.ToSummary(); }; importer.Load(input); Assert.AreEqual(activity.AvgHeartRate, 153); Assert.AreEqual(activity.MaxHeartRate, 180); } }
private async Task <Tuple <MemoryActivity, MemoryActivity> > StripAsync(StripOptions options, bool log = false) { var strippedFileName = GetStrippedFileName(FileName); using (var input = await TestFileHelper.OpenForReadAsync(FileName)) { var stripper = new FitStripper { LogEnabled = log }; using (var output = await TestFileHelper.OpenForWriteAsync(strippedFileName)) { stripper.Strip(input, output, options); } } var activity = await LoadAsync(FileName); var strippedActivity = await LoadAsync(strippedFileName); return(new Tuple <MemoryActivity, MemoryActivity>(activity, strippedActivity)); }
public async Task ImportCycling() { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(Hrm106Cycling)) { var importer = new HrmImporter(activity); importer.Load(input); Assert.AreEqual(Dynastream.Fit.Sport.Cycling, activity.Sport); Assert.AreEqual(new DateTime(2009, 05, 21, 06, 58, 41), activity.StartTime); Assert.AreNotEqual(0, activity.TimeFrames.Count); Assert.AreEqual(new TimeSpan(11, 59, 41).TotalSeconds, activity.ElapsedTime, 30); // treshold = 2 x recording interval Assert.AreEqual(239.1f, activity.Distance.GetValueAs(DistanceUnit.Kilometer), 0.1f); Assert.AreEqual(20.1f, activity.AvgSpeed.GetValueAs(SpeedUnit.KilometerPerHour), 0.1f); Assert.AreEqual(53.8f, activity.MaxSpeed.GetValueAs(SpeedUnit.KilometerPerHour), 0.1f); Assert.AreEqual(477, activity.TimeFrames[4].Altitude.Value.GetValueAs(DistanceUnit.Meter)); } // now check exporting it ExportReloadCheck(activity); }
public async Task ImportRunning() { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(Hrm106Running)) { var importer = new HrmImporter(activity); importer.Load(input); Assert.AreEqual(Dynastream.Fit.Sport.Running, activity.Sport); Assert.AreEqual(new DateTime(2007, 12, 31, 09, 05, 29), activity.StartTime); Assert.AreNotEqual(0, activity.TimeFrames.Count); Assert.AreEqual(new TimeSpan(03, 58, 59).TotalSeconds, activity.ElapsedTime, 30); // treshold = 2 x recording interval //Assert.AreEqual(135.6f, activity.Distance.GetValueAs(DistanceUnit.Kilometer), 0.1f); //Assert.AreEqual(26.9f, activity.AvgSpeed.GetValueAs(SpeedUnit.KilometerPerHour), 0.1f); //Assert.AreEqual(56.9f, activity.MaxSpeed.GetValueAs(SpeedUnit.KilometerPerHour), 0.1f); //Assert.AreEqual(94, activity.TimeFrames[3].Cadence.Value); //Assert.AreEqual(191, activity.TimeFrames[3].Altitude.Value.GetValueAs(DistanceUnit.Meter)); } // now check exporting it ExportReloadCheck(activity); }
public async Task ImportCyclingPower() { var activity = new MemoryActivity(); using (var input = await TestFileHelper.OpenForReadAsync(Hrm106CyclingPower)) { var importer = new HrmImporter(activity); importer.Load(input); Assert.AreEqual(Dynastream.Fit.Sport.Cycling, activity.Sport); Assert.AreEqual(new DateTime(2009, 01, 03, 11, 54, 23), activity.StartTime); Assert.AreNotEqual(0, activity.TimeFrames.Count); Assert.AreEqual(new TimeSpan(02, 43, 30).TotalSeconds, activity.ElapsedTime, 30); // treshold = 2 x recording interval Assert.AreEqual(66.8f, activity.Distance.GetValueAs(DistanceUnit.Kilometer), 0.1f); Assert.AreEqual(25.3f, activity.AvgSpeed.GetValueAs(SpeedUnit.KilometerPerHour), 0.1f); Assert.AreEqual(51.8f, activity.MaxSpeed.GetValueAs(SpeedUnit.KilometerPerHour), 0.1f); Assert.True(activity.TimeFrames.Count > 3); Assert.AreEqual(66, activity.TimeFrames[3].Cadence.Value); Assert.AreEqual(174, activity.TimeFrames[3].Altitude.Value.GetValueAs(DistanceUnit.Meter)); Assert.AreEqual(16, activity.TimeFrames[3].Power.Value); } // now check exporting it ExportReloadCheck(activity); }