Workout2TCX { public void document(Workout workout, List<Snapshot> snaoshots) throws IOException { serializer.startDocument("UTF-8", true); trainingCenterDatabase(workout, snaoshots); serializer.endDocument(); } Workout2TCX(Writer writer, ICourse track); void document(Workout workout, List<Snapshot> snaoshots);  }
@Test public void empty() throws IOException { Workout workout = new Workout(); workout.start.set(Mon_Jun_15_2015); workout.duration.set(2); workout.distance.set(6); workout.strokes.set(2); workout.energy.set(3); List<Snapshot> snapshots = new ArrayList<>(); StringWriter writer = new StringWriter(); new Workout2TCX(writer, new StationaryCourse(null)).document(workout, snapshots); assertContent(getClass().getResourceAsStream("/empty.tcx"), writer.toString()); }
@Test public void snapshots() throws IOException { Program program = new Program(); program.name.set("Test Program"); Workout workout = new Workout(); workout.program.set(program); workout.start.set(Mon_Jun_15_2015 + (60 * 1000)); workout.duration.set(2); workout.distance.set(6); workout.strokes.set(2); workout.energy.set(3); List<Snapshot> snapshots = new ArrayList<>(); Snapshot snapshot = new Snapshot(); snapshot.speed.set(4_50); snapshot.pulse.set(80); snapshot.strokeRate.set(25); snapshot.distance.set(2); snapshot.strokes.set(0); snapshot.power.set(0); snapshots.add(snapshot); snapshot = new Snapshot(); snapshot.speed.set(4_51); snapshot.pulse.set(81); snapshot.strokeRate.set(26); snapshot.distance.set(4); snapshot.strokes.set(1); snapshot.power.set(1); snapshots.add(snapshot); snapshot = new Snapshot(); snapshot.speed.set(4_52); snapshot.pulse.set(82); snapshot.strokeRate.set(27); snapshot.distance.set(6); snapshot.strokes.set(2); snapshot.power.set(2); snapshots.add(snapshot); StringWriter writer = new StringWriter(); new Workout2TCX(writer, new StationaryCourse(null)).document(workout, snapshots); assertContent(getClass().getResourceAsStream("/snapshots.tcx"), writer.toString()); }