public void ErrorOnBadExtension() { var factory = new TcxDataFactory(null, null, null); Exception e = ExceptionAssert.Throws<Exception>(() => factory.Create(new SourcedStream() { Source = "joe.zzz" })); StringAssert.Contains(e.Message, ".zzz"); StringAssert.Contains(e.Message, "not a supported file type"); }
public void TestInitialize() { testFactory = new TcxDataFactory( (r) => { lemondData.Reader = r; return lemondData; }, (r) => { computrainer3DPData.Reader = r; return computrainer3DPData; }, (r) => { computrainerTXTData.Reader = r; return computrainerTXTData; }); }
public void WriteTcxFile(IEnumerable <SourcedStream> laps, TextWriter textWriter) { using (TcxWriter writer = new TcxWriter(textWriter)) { writer.StartTcx(); bool firstFile = true; LapStats stats = new LapStats() { Calories = 0, DistanceMeters = 0, TotalTimeSeconds = 0 }; foreach (var lap in laps) { var data = TcxDataFactory.CreateDefault().Create(lap); if (firstFile) { writer.StartActivity(data.StartTime, data.Sport); firstFile = false; } writer.StartLap(data.StartTime); foreach (var point in data.TrackPoints) { writer.StartTrackPoint(); writer.WriteTrackPointTime(point.Time); writer.WriteTrackPointCadence(point.CadenceRpm); writer.WriteTrackPointElapsedCalories(point.CaloriesElapsed + stats.Calories); writer.WriteTrackPointElapsedDistanceMeters(point.DistanceMetersElapsed + stats.DistanceMeters); writer.WriteTrackPointHeartRateBpm(point.HeartRateBpm); writer.WriteTrackPointPowerWatts(point.PowerWatts); writer.WriteTrackPointSpeedMetersPerSecond(point.SpeedMetersPerSecond); writer.EndTrackPoint(); } stats = writer.EndLap(); } writer.EndActivity(); writer.EndTcx(); } }