public void Men2_FromTables() { decimal bodyWeight = 76.5m; decimal liftedWeight = 245.5m; Assert.AreEqual(172.56195, WilksFormula.CalculateForMenUsingTables(bodyWeight, liftedWeight)); }
public void Men4_MoreThan206() { decimal bodyWeight = 241m; decimal liftedWeight = 200.5m; Assert.AreEqual(121.4661m, Math.Round(WilksFormula.CalculateForMen(bodyWeight, liftedWeight), 4)); }
public void PaceFromSpeed() { var speed = 11.66666666666667;//m/s var pace = WilksFormula.SpeedToPace((float)speed); Assert.AreEqual("00:01:25", WilksFormula.PaceToString(pace)); }
public void PaceFromSpeed_ShowWithoutHours() { var speed = 11.66666666666667;//m/s var pace = WilksFormula.SpeedToPace((float)speed); Assert.AreEqual("01:25", WilksFormula.PaceToString(pace, true)); }
public void Women2_FromTables() { decimal bodyWeight = 100; decimal liftedWeight = 340; Assert.AreEqual(283.084, WilksFormula.CalculateForWomenUsingTables(bodyWeight, liftedWeight)); }
public void PaceFromDistanceAndTime() { var pace = TimeSpan.FromMinutes(50).TotalSeconds / 35; var paceTimeString = WilksFormula.PaceToString((float)pace); Assert.AreEqual("00:01:25", paceTimeString); }
public void Women3_LowerThan40() { decimal bodyWeight = 32m; decimal liftedWeight = 134.5m; Assert.AreEqual(220.4120m, Math.Round(WilksFormula.CalculateForWomen(bodyWeight, liftedWeight), 4)); }
public static decimal?CalculateCalories(decimal met, decimal?duration, IPerson person) { if (duration == null) {//we don't have time of exercising then we cannot calculate calories return(null); } DateTime?birthday = null; Gender gender = Gender.Male; decimal weight = 0; decimal height = 0; if (person.Birthday != null) { birthday = person.Birthday; } gender = person.Gender; if (person.Wymiary != null) { weight = person.Wymiary.Weight; height = person.Wymiary.Height; } if (gender == Gender.NotSet) { gender = Gender.Male; } if (weight == 0) {//set default weight if not defined if (gender == Gender.Female) { weight = 70; } else { weight = 100; } } if (gender == Gender.Male) { if (height == 0) { height = 177.4M; } } else {//female if (height == 0) { height = 163M; } } if (birthday == null) {//if birthday is not set then assume 30 years old birthday = DateTime.UtcNow.AddYears(-30).AddDays(-1); } int age = birthday.Value.GetAge(); return(WilksFormula.CalculateCaloriesUsingMET(gender == Gender.Male, met, TimeSpan.FromSeconds((double)duration), age, weight, height)); }
public void Women4_MoreThan206() { decimal bodyWeight = 170m; decimal liftedWeight = 200.5m; Assert.AreEqual(158.9952m, Math.Round(WilksFormula.CalculateForWomen(bodyWeight, liftedWeight), 4)); }
public void Women1_FromTables() { decimal bodyWeight = 60; decimal liftedWeight = 70; Assert.AreEqual(78.043, WilksFormula.CalculateForWomenUsingTables(bodyWeight, liftedWeight)); }
public void Men1_FromTables() { decimal bodyWeight = 100; decimal liftedWeight = 340; Assert.AreEqual(206.924, WilksFormula.CalculateForMenUsingTables(bodyWeight, liftedWeight)); }
public void SpeedToPace() { var speed = 12;//m/s var pace = WilksFormula.SpeedToPace((float)speed); Assert.AreEqual("01:23", WilksFormula.PaceToString(pace, true)); //min/km pace = WilksFormula.SpeedToPace((float)speed, true); Assert.AreEqual("02:15", WilksFormula.PaceToString(pace, true)); //min/mile }
void fillInfo() { pivot.Items.Remove(tpWorkout); if (!pivot.Items.Contains(tpSummary)) { pivot.Items.Add(tpSummary); } pivot.SelectedItem = tpSummary; if (viewModel.Entry.Duration.HasValue) { tbSummaryDuration.Text = viewModel.Entry.Duration.Value.ToDisplayDuration().ToString(); } tbSummaryExercise.Text = viewModel.Entry.Exercise.Name; if (viewModel.HasDistance) { tbSummaryDistance.Text = viewModel.Entry.Distance.Value.ToDisplayDistance().ToString("0.##"); } if (viewModel.HasMaxSpeed) { tbSummaryMaxSpeed.Text = viewModel.Entry.MaxSpeed.Value.ToDisplaySpeed().ToString("0.##"); } if (viewModel.HasAvgSpeed) { tbSummaryAvgSpeed.Text = viewModel.Entry.AvgSpeed.Value.ToDisplaySpeed().ToString("0.##"); tbSummaryAvgPace.Text = WilksFormula.PaceToString((float)viewModel.Entry.AvgSpeed.Value.ToDisplayPace(), true); } if (viewModel.HasMaxAlt) { tbSummaryMaxAltitude.Text = viewModel.Entry.MaxAltitude.Value.ToDisplayAltitude().ToString("0.#"); } if (viewModel.HasMinAlt) { tbSummaryMinAltitude.Text = viewModel.Entry.MinAltitude.Value.ToDisplayAltitude().ToString("0.#"); } if (viewModel.HasCalories) { tbSummaryCalories.Text = Math.Round(viewModel.Entry.Calories.Value).ToString(); } if (viewModel.HasWeather) { var image = new BitmapImage(new Uri(string.Format("/Images/Weather/{0}", WeatherIcon.GetIcon(viewModel.Entry.Weather.Condition)), UriKind.RelativeOrAbsolute)); imgWeather.Source = image; if (viewModel.Entry.Weather.Temperature.HasValue) { tbSummaryTemperature.Text = viewModel.Entry.Weather.Temperature.Value.ToString(); } } }
decimal calculateWilks(Customer customer, decimal bodyWeight, decimal exerciseWeight) { if (bodyWeight <= 0) { return(0); } if (customer.Gender == Gender.Male) { return(WilksFormula.CalculateForMenUsingTables(bodyWeight, exerciseWeight)); } if (customer.Gender == Gender.Female) { return(WilksFormula.CalculateForWomenUsingTables(bodyWeight, exerciseWeight)); } throw new ArgumentException("Customer without gender!"); }
private void btnCalculate_Click(object sender, RoutedEventArgs e) { var bodyKgWeight = ((double?)BodyWeight).ToSaveWeight(); var totalKgWeight = ((double?)TotalWeight).ToSaveWeight(); if (IsMale) { var result = WilksFormula.CalculateForMenUsingTables(bodyKgWeight, totalKgWeight); Wilks = result.ToString("#.####"); } else { var result = WilksFormula.CalculateForWomenUsingTables(bodyKgWeight, totalKgWeight); Wilks = result.ToString("#.####"); } }
public static decimal ToDisplayPace(this decimal mPerSec) { return((decimal)WilksFormula.SpeedToPace((float)mPerSec, ApplicationState.Current.ProfileInfo.Settings.LengthType == Service.V2.Model.LengthType.Inchs)); }
public void Calculator1() { var calories = WilksFormula.CalculateCalories(90, TimeSpan.FromMinutes(70), 3.62M); Assert.AreEqual(837M, calories); }
public static decimal ToDisplayPace(this decimal mPerSec) { return((decimal)WilksFormula.SpeedToPace((float)mPerSec, UserContext.Current.ProfileInformation.Settings.LengthType == LengthType.Inchs)); }
public void CalculatorUsingMet_Male() { var calories = WilksFormula.CalculateCaloriesUsingMET(true, 8.0m, TimeSpan.FromMinutes(60), 32, 93, 188); Assert.AreEqual(689m, calories); }
public void CalculatorUsingMet_Female() { var calories = WilksFormula.CalculateCaloriesUsingMET(false, 8.0m, TimeSpan.FromMinutes(60), 32, 93, 188); Assert.AreEqual(581m, (int)calories); }