public void CalculateNormalizedPower_With_No_Samples_Returns_Zero()
 {
     var samples = new WorkoutSamples(0);
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(samples,athlete);
     var average = workoutCalculator.GetNormalizedPower();
     Assert.Equal(0, average);
 }
 public void CalculateNonZero_Average_With_No_Data_Returns_Zero()
 {
     var samples = new WorkoutSamples(0);
     var vector = new WorkoutSampleVector(3, WorkoutSampleDataType.Power);
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete);
     var average = workoutCalculator.CalculateNonZeroVectorAverage(vector);
     Assert.Equal(0, average);
 }
 public void CalculatCadenceClassificatoion_Under_2_Samples_returns_()
 {
     var samples = new WorkoutSamples(0);
     var vector = new WorkoutSampleVector(1, WorkoutSampleDataType.Cadence);
     vector.AddPoint(1, 2);
     samples.CadenceVector = vector;
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete);
     var classification = workoutCalculator.ClassifyWorkoutCadenceRanges();
     Assert.IsType<List<ICadenceRange>>(classification);
 }
 public void CalculateNormalizedPower_With_Under_30_Samples_Returns_Average()
 {
     //Initialise();
     var samples = new WorkoutSamples(0);
     var vector = new WorkoutSampleVector(2, WorkoutSampleDataType.Power);
     vector.AddPoint(1, 2);
     vector.AddPoint(2, 4);
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete);
     var average = workoutCalculator.CalculateVectorNormalizedAverage(vector);
     Assert.Equal(3, average);
 }
 public void CalculateNonZero_Average_Returns_Average()
 {
     var samples = new WorkoutSamples(0);
     var vector = new WorkoutSampleVector(3, WorkoutSampleDataType.Power);
     vector.AddPoint(1, 2);
     vector.AddPoint(2, 4);
     vector.AddPoint(3, 0);
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(samples,athlete);
     var average = workoutCalculator.CalculateNonZeroVectorAverage(vector);
     Assert.Equal(3, average);
 }
 public static IWorkout MapExtendedCycleWorkout(pwx pwx, IWorkout shortWorkout)
 {
     pwxWorkout pwxWo = pwx.workout[0];
     IAthlete athlete = new Athlete();
     athlete.FTBikePower = 231;
     shortWorkout.TrainingStressScore = pwxWo.summarydata.tss;
     ICycleWorkout cycleWorkout = shortWorkout as ICycleWorkout;
     if (cycleWorkout == null)
         return shortWorkout;
     PWXDataExtractor dataExtractor = new PWXDataExtractor(pwx);
     var workoutSamples = dataExtractor.ExtractData();
     WorkoutSamplesCalculator calc = new WorkoutSamplesCalculator(workoutSamples, athlete);
     cycleWorkout.IntensityFactor = calc.CalcualteIntensityFactor();
     cycleWorkout.NormalizedPower = (int)calc.GetNormalizedPower();
     
     return shortWorkout;
 }
 public void CalculateVectorAverage_With_No_Samples_Returns_Zero()
 {
     var samples = new WorkoutSamples(0);
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete);
     var average = workoutCalculator.GetAverageCadence();
     Assert.Equal(0, average);
 }
 public void Test_Workout_Energy_System_Classiication_with_Power()
 {
     Initialise();
     var data = new PWXDataExtractor(_test);
     var samples = data.ExtractData();
     IAthlete athlete = new Athlete();
     var calc = new WorkoutSamplesCalculator(samples, athlete);
     var systems = calc.ClassifyWorkoutPowerRanges(240);
     Assert.IsType<List<IEnergySystemRange>> (systems);
 }
 public void TestPowerBasedTrainingStressScoreCalculation()
 {
     Initialise();
     var calc = new PWXDataExtractor(_test);
     var workoutSample = calc.ExtractData();
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(workoutSample, athlete);
     var summaryTSS = _test.workout[0].summarydata.tss;
     var roundedTPTSS = Math.Round(summaryTSS, 0);
     var myTSSCalc = workoutCalculator.Calculate_Power_TrainingStressScore(272);
     var roundedMyTSS = Math.Round(myTSSCalc, 0);
     Assert.Equal(roundedTPTSS, roundedMyTSS);
 }
 public void TestNormalizedPower()
 {
     Initialise();
     var calc = new PWXDataExtractor(_test);
     var workoutSample = calc.ExtractData();
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(workoutSample, athlete);
     var myPowerAverage = workoutCalculator.GetNormalizedPower();
     Assert.Equal(231, myPowerAverage);
 }
 public void TestIntensityFactor()
 {
     Initialise();
     var calc = new PWXDataExtractor(_test);
     var workoutSample = calc.ExtractData();
     IAthlete athlete = new Athlete();
     athlete.FTBikePower = 240;
     var workoutCalculator = new WorkoutSamplesCalculator(workoutSample,athlete);
     var intensityFactor = workoutCalculator.CalcualteIntensityFactor();
     Assert.Equal(0.96, intensityFactor);
 }
 public void TestCadenceClassification()
 {
     var pwx =
         GetPwxDataFromXml(
             GetSamplePwxFile(@"c:\dev\autocoach\testxmldata\TestTurboPowerCyclePZoneClassificationPWX.xml"));
     var dataExtractor = new PWXDataExtractor(pwx);
     var workoutSample = dataExtractor.ExtractData();
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(workoutSample,athlete);
     var buckets = workoutCalculator.ClassifyWorkoutCadenceRanges();
     Assert.IsType<List<ICadenceRange>>(buckets);
     Assert.Equal(1, buckets[0].QuanityOfSamples);
     Assert.Equal(14, buckets[0].PercentOfTotal);
     Assert.Equal(3, buckets[1].QuanityOfSamples);
     Assert.Equal(43, buckets[1].PercentOfTotal);
     Assert.Equal(0, buckets[2].QuanityOfSamples);
     Assert.Equal(0, buckets[2].PercentOfTotal);
     Assert.Equal(2, buckets[3].QuanityOfSamples);
     Assert.Equal(29, buckets[3].PercentOfTotal);
     Assert.Equal(1, buckets[4].QuanityOfSamples);
     Assert.Equal(14, buckets[4].PercentOfTotal);
 }
 public void TestAverageSpeed()
 {
     Initialise();
     var calc = new PWXDataExtractor(_test);
     var workoutSample = calc.ExtractData();
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(workoutSample,athlete);
     var mySpdAverage = workoutCalculator.GetAverageSpeed();
     // double pwxSummaryAvgHR = _test.workout[0].summarydata.spd.avg;
     mySpdAverage = Math.Round(mySpdAverage);
     //Assert.Equal(mySpdAverage, pwxSummaryAvgHR);
 }
 public void TestAveragePower()
 {
     Initialise();
     var calc = new PWXDataExtractor(_test);
     var workoutSample = calc.ExtractData();
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(workoutSample,athlete);
     var myPowerAverage = workoutCalculator.GetAveragePower();
     var pwxSummaryPowerAverage = _test.workout[0].summarydata.pwr.avg;
     myPowerAverage = Math.Round(myPowerAverage);
     Assert.Equal(pwxSummaryPowerAverage, myPowerAverage);
 }
        public Athlete SetupFakeAthlete(string username, string password, TrainingPeaksAthleteAccountTypes accountType)
        {
            var athlete = new Athlete
            {
                TPData = new TrainingPeaksAthleteData
                {
                    LoginName = username,
                    LoginPassword = password,
                    AccountType = accountType
                }
            };

            return athlete;
        }