Example #1
0
        public void Should_multiply_reps_by_appropriate_level_for_each_workout_when_there_are_mixed_levels()
        {
            var physioWorkout = new PhysioCircuit();

            physioWorkout.LogList.Add(new CircuitLog
            {
                Variant = Variant.Normal,
                Level   = 1,
                NumberOfRoundsPerformed = 3
            });

            physioWorkout.LogList.Add(new CircuitLog
            {
                Variant = Variant.Normal,
                Level   = 2,
                NumberOfRoundsPerformed = 3
            });

            physioWorkout.LogList.Add(new CircuitLog
            {
                Variant = Variant.Normal,
                Level   = 3,
                NumberOfRoundsPerformed = 3
            });

            var numberOfCrunches = physioWorkout.GetTotalCrunchesPerformed();
            var numberOfBridges  = physioWorkout.GetTotalBridgesPerformed();
            var numberOfSquats   = physioWorkout.GetTotalSquatsPerformed();

            Assert.AreEqual(225, numberOfCrunches);
            Assert.AreEqual(135, numberOfBridges);
            Assert.AreEqual(135, numberOfSquats);
        }
        private void CreateCurrentWeekStatsSection(List <Workout> workouts, LinearLayout currentWeekStatsLayout)
        {
            var logsForWeek = _circuitLogService.SelectRunningWeeksLogsFromWorkouts();

            var physioCircuitWorkout = new PhysioCircuit();

            physioCircuitWorkout.LogList.AddRange(logsForWeek);
            var totalBridgesForWeek  = physioCircuitWorkout.GetTotalBridgesPerformed();
            var totalSquatsForWeek   = physioCircuitWorkout.GetTotalSquatsPerformed();
            var averageBridgesPerDay = totalBridgesForWeek / 7;
            var averageSquatsPerDay  = totalSquatsForWeek / 7;

            var orderedListOfPointsForWeek = logsForWeek
                                             .GroupBy(x => x.WorkoutDate.DayOfWeek)
                                             .Select(x => x.Sum(y => y.GetPoints()))
                                             .OrderBy(x => x).ToList();
            var daysWithWorkoutsCount    = orderedListOfPointsForWeek.Count();
            var daysWithoutWorkoutsCount = 7 - daysWithWorkoutsCount;

            currentWeekStatsLayout.AddView(new TextView(currentWeekStatsLayout.Context)
            {
                Text = $"{totalBridgesForWeek} bridges this week! {averageBridgesPerDay} on average per day!"
            });
            currentWeekStatsLayout.AddView(new TextView(currentWeekStatsLayout.Context)
            {
                Text = $"{totalSquatsForWeek} squats this week! {averageSquatsPerDay} on average per day!"
            });
        }
Example #3
0
        public void Should_multiply_reps_by_level_for_level_2()
        {
            var log = new CircuitLog
            {
                Variant = Variant.Normal,
                Level   = 2,
                NumberOfRoundsPerformed = 3
            };

            var physioWorkout = new PhysioCircuit();

            physioWorkout.LogList.Add(log);

            var numberOfCrunches = physioWorkout.GetTotalCrunchesPerformed();
            var numberOfBridges  = physioWorkout.GetTotalBridgesPerformed();
            var numberOfSquats   = physioWorkout.GetTotalSquatsPerformed();

            Assert.AreEqual(75, numberOfCrunches);
            Assert.AreEqual(45, numberOfBridges);
            Assert.AreEqual(45, numberOfSquats);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var circuitLogRepository    = new CircuitLogRepository();
            var meditationLogRepository = new MeditationLogRepository();
            var waterLogRepository      = new WaterLogRepository();
            var physioCircuitWorkout    = new PhysioCircuit();

            physioCircuitWorkout.LogList.AddRange(circuitLogRepository.Get());
            _circuitLogService = new CircuitLogService(circuitLogRepository);

            var workouts = new List <Workout>()
            {
                physioCircuitWorkout
            };

            var meditations = meditationLogRepository.GetForWeek().ToList();
            var waterLogs   = waterLogRepository.GetForWeek().ToList();
            var layout      = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            var table = BuildTableLayoutFromWorkouts(workouts, meditations, waterLogs, this);

            layout.AddView(table);

            var reportsHorizontalLayout = new LinearLayout(layout.Context)
            {
                Orientation = Orientation.Vertical
            };
            var currentWeekStatsVerticalLayout = new LinearLayout(layout.Context)
            {
                Orientation = Orientation.Vertical
            };
            var pointsHistoryVerticalLayout = new LinearLayout(layout.Context)
            {
                Orientation = Orientation.Horizontal
            };
            var pointsAggregatesVerticalLayout = new LinearLayout(layout.Context)
            {
                Orientation = Orientation.Vertical
            };
            var currentLevelVerticalLayout = new LinearLayout(layout.Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(reportsHorizontalLayout);
            reportsHorizontalLayout.AddView(currentWeekStatsVerticalLayout);
            reportsHorizontalLayout.AddView(pointsHistoryVerticalLayout);
            reportsHorizontalLayout.AddView(pointsAggregatesVerticalLayout);
            reportsHorizontalLayout.AddView(currentLevelVerticalLayout);

            currentWeekStatsVerticalLayout.SetPadding(5, 5, 5, 5);
            pointsHistoryVerticalLayout.SetPadding(5, 5, 5, 5);
            pointsAggregatesVerticalLayout.SetPadding(5, 5, 5, 5);

            CreateCurrentWeekStatsSection(workouts, currentWeekStatsVerticalLayout);
            CreateHistorySection(workouts, pointsHistoryVerticalLayout, pointsAggregatesVerticalLayout);

            var currentLevelText = new TextView(this)
            {
                Text = "Level " + Workout.CURRENT_LEVEL.ToString()
            };

            currentLevelText.SetPadding(5, 5, 5, 5);
            currentLevelText.SetTextColor(new Color(255, 255, 255));
            currentLevelVerticalLayout.AddView(currentLevelText);

            currentLevelVerticalLayout.AddView
            (
                BuildProgressBarChart
                (
                    steps: new int[] { 12, 15, 22 },
                    goal: 40,
                    title: "Continuous Pushups",
                    icon: Resource.Drawable.Pushups
                )
            );

            var crunchesPerDayData = new List <int>();

            for (int i = 0; i < 7; i++)
            {
                var referenceDate     = DateTime.Now.AddDays(-i);
                var logs              = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(referenceDate);
                var circuit           = new PhysioCircuit(logs);
                var crunchesPerformed = circuit.GetTotalCrunchesPerformed();
                var averagePerDay     = crunchesPerformed / 7;
                crunchesPerDayData.Add(averagePerDay);
            }

            currentLevelVerticalLayout.AddView
            (
                BuildProgressBarChart
                (
                    steps: crunchesPerDayData.ToArray(),
                    goal: 200,
                    title: "Crunches per day",
                    icon: Resource.Drawable.Crunches
                )
            );

            currentLevelVerticalLayout.AddView
            (
                BuildProgressBarChart
                (
                    steps: new int[] { 50, 60, 67, 68, 66, 63, 50 },
                    goal: 100,
                    title: "Crunches in a minute",
                    icon: Resource.Drawable.Crunches
                )
            );

            SetContentView(layout);
        }