public void DomainController_GetMontlyReport_ReceivedMontlyReport() { DC.AddCyclingTraining(new DateTime(2020, 4, 21, 16, 00, 00), 40, new TimeSpan(1, 20, 00), 30, null, TrainingType.Endurance, null, BikeType.RacingBike); DC.AddRunningTraining(new DateTime(2020, 4, 17, 12, 30, 00), 5000, new TimeSpan(0, 27, 17), null, TrainingType.Endurance, null); var montly = DC.GetMonlyReport(2020, 4).TimeLine; // if(montly[0].Item2 is CyclingSession) RunningSession tempRunn = (RunningSession)montly[0].Item2; tempRunn.When.Should().Be(_running.When); tempRunn.Distance.Should().Be(_running.Distance); tempRunn.Time.Should().Be(_running.Time); tempRunn.AverageSpeed.Should().Be(_running.AverageSpeed); tempRunn.TrainingType.Should().Be(_running.TrainingType); tempRunn.Comments.Should().Be(_running.Comments); CyclingSession tempCycle = (CyclingSession)montly[1].Item2; tempCycle.When.Should().Be(_cycling.When); tempCycle.Distance.Should().Be(_cycling.Distance); tempCycle.Time.Should().Be(_cycling.Time); tempCycle.AverageSpeed.Should().Be(_cycling.AverageSpeed); tempCycle.AverageWatt.Should().Be(_cycling.AverageWatt); tempCycle.TrainingType.Should().Be(_cycling.TrainingType); tempCycle.Comments.Should().Be(_cycling.Comments); tempCycle.BikeType.Should().Be(_cycling.BikeType); }
private void DialogGenerateClickEevent(object sender, RoutedEventArgs e) { DateTime inputDate = new DateTime(); try { inputDate = InputDate.SelectedDate.Value; } catch (Exception) { MessageBox.Show("You must fill in the date"); return; } if (inputDate > DateTime.Now) { MessageBox.Show("You can't select a date in the future"); return; } TrainingManager manager = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); Report rapport = manager.GenerateMonthlyTrainingsReport(inputDate.Year, inputDate.Month); if (rapport.TotalTrainingTime.ToString(@"h\h") != "0h") { CountTime.Text = rapport.TotalTrainingTime.ToString(@"h\h") + " " + rapport.TotalTrainingTime.ToString(@"m\m"); } else { CountTime.Text = rapport.TotalCyclingTrainingTime.ToString(@"m\m"); } CountRunning.Text = (rapport.CyclingSessions + rapport.RunningSessions).ToString(); CountDistance.Text = (rapport.TotalCyclingDistance + (rapport.TotalRunningDistance / 1000)) + "km"; dataTable.Clear(); RunningSession maxRunDistance = rapport.MaxDistanceSessionRunning; addDataLine("Distance", "Running", maxRunDistance.TrainingType.ToString(), maxRunDistance.Distance + " m", maxRunDistance.Time, Math.Round(maxRunDistance.AverageSpeed, 2) + " km/h", "", "", maxRunDistance.When, maxRunDistance.Comments); RunningSession maxRunSpeed = rapport.MaxSpeedSessionRunning; addDataLine("Speed", "Running", maxRunSpeed.TrainingType.ToString(), maxRunSpeed.Distance + " m", maxRunSpeed.Time, Math.Round(maxRunSpeed.AverageSpeed, 2) + " km/h", "", "", maxRunSpeed.When, maxRunSpeed.Comments); CyclingSession maxDistance = rapport.MaxDistanceSessionCycling; addDataLine("Distance", "Cycling", maxDistance.TrainingType.ToString(), maxDistance.Distance + " km", maxDistance.Time, Math.Round(Convert.ToDecimal(maxDistance.AverageSpeed), 2) + " km/h", maxDistance.AverageWatt.ToString(), maxDistance.BikeType.ToString(), maxDistance.When, maxDistance.Comments); CyclingSession maxSpeed = rapport.MaxSpeedSessionCycling; addDataLine("Speed", "Cycling", maxSpeed.TrainingType.ToString(), maxSpeed.Distance + " km", maxSpeed.Time, Math.Round(Convert.ToDecimal(maxSpeed.AverageSpeed), 2) + " km/h", maxSpeed.AverageWatt.ToString(), maxSpeed.BikeType.ToString(), maxSpeed.When, maxSpeed.Comments); CyclingSession maxWatt = rapport.MaxWattSessionCycling; addDataLine("Watt", "Cycling", maxWatt.TrainingType.ToString(), maxWatt.Distance + " km", maxWatt.Time, Math.Round(Convert.ToDecimal(maxWatt.AverageSpeed), 2) + " km/h", maxWatt.AverageWatt.ToString(), maxWatt.BikeType.ToString(), maxWatt.When, maxWatt.Comments); Dialog.IsOpen = false; }
public void TestRemovingCyclingSessionFromDatabase() { //Arrange TrainingManager m = new TrainingManager(new UnitOfWork(new TrainingContextTest())); DateTime now = DateTime.Now; CyclingSession cS = new CyclingSession(now, null, new TimeSpan(2, 0, 0), null, null, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession ToDeleteSessions = new CyclingSession(new DateTime(2010, 5, 12), null, new TimeSpan(2, 0, 0), null, null, TrainingType.Endurance, null, BikeType.IndoorBike); m.AddCyclingTraining(ToDeleteSessions.When, ToDeleteSessions.Distance, ToDeleteSessions.Time, ToDeleteSessions.AverageSpeed, ToDeleteSessions.AverageWatt, ToDeleteSessions.TrainingType, ToDeleteSessions.Comments, ToDeleteSessions.BikeType); m.AddCyclingTraining(cS.When, cS.Distance, cS.Time, cS.AverageSpeed, cS.AverageWatt, cS.TrainingType, cS.Comments, cS.BikeType); //Act TrainingManager m2 = new TrainingManager(new UnitOfWork(new TrainingContextTest(true))); m2.RemoveTrainings(new List <int>() { 1 }, new List <int>()); var cyclingSessions = m2.GetAllCyclingSessions(); CyclingSession retrievedCycle = cyclingSessions[0]; //Assert Assert.IsTrue(cyclingSessions.Count == 1, "The Running Session was not deleted"); Assert.AreEqual(retrievedCycle.AverageSpeed, cS.AverageSpeed, "AverageSpeed did not match up"); Assert.AreEqual(retrievedCycle.Comments, cS.Comments, "Comments did not match up"); Assert.AreEqual(retrievedCycle.Distance, cS.Distance, "Distance did not match up"); Assert.AreEqual(retrievedCycle.Time, cS.Time, "Time did not match up"); Assert.AreEqual(retrievedCycle.TrainingType, cS.TrainingType, "TrainingType did not match up"); Assert.AreEqual(retrievedCycle.When, cS.When, "When did not match up"); Assert.AreEqual(retrievedCycle.BikeType, cS.BikeType, "BikeType did not match up"); }
public void TestCorrectBindings() { //Arrange DateTime now = DateTime.Now; float distance = 5.4f; TimeSpan time = new TimeSpan(2, 3, 4); float speed = 4.8f; int watt = 12; TrainingType training = TrainingType.Endurance; string comment = "test comment"; BikeType bike = BikeType.CityBike; //Act CyclingSession cyclingSession = new CyclingSession(now, distance, time, speed, watt, training, comment, bike); //Assert Assert.AreEqual(cyclingSession.When, now, "StartTime was not bound properly"); Assert.AreEqual(cyclingSession.Distance, distance, "Distance was not bound properly"); Assert.AreEqual(cyclingSession.Time, time, "Duration was not bound properly"); Assert.AreEqual(cyclingSession.AverageSpeed, speed, "Average Speed was not bound properly"); Assert.AreEqual(cyclingSession.AverageWatt, watt, "AverageWatt was not bound properly"); Assert.AreEqual(cyclingSession.TrainingType, training, "TrainingType was not bound properly"); Assert.AreEqual(cyclingSession.Comments, comment, "Comments was not bound properly"); Assert.AreEqual(cyclingSession.BikeType, bike, "BikeType was not bound properly"); }
public void TestLoadSessionCycling() { FileReader f = new FileReader(); string path = @"C:\own\programming\projects\TrainingAnalysisFull\TrainingAnalysisGUI\sessions\Petter_Stenhagen_2019-07-30_17-02-02.tcx"; string session = f.readFile(path); string startTime = TrainingSession.getHeaderInfo(session)["startTime"]; CyclingSession cs = new CyclingSession(startTime); bool success = cs.loadSessionBody(session); Assert.IsTrue(success); Assert.AreEqual(2516, cs.mTimeVector.Count); // First Assert.AreEqual(0, cs.mTimeVector[0]); Assert.IsNull(cs.mPosVector[0]); DoubleWithinMargin(TrainingSession.AltError, cs.mAltVector[0], 0.000001); DoubleWithinMargin(TrainingSession.DistError, cs.mDistVector[0], 0.000001); Assert.AreEqual(TrainingSession.HRError, cs.mHRVector[0]); // next to last int i = 2514; Assert.AreEqual(i, cs.mTimeVector[i]); DoubleWithinMargin(58.52981167, cs.mPosVector[i].mLatitude, 0.000001); DoubleWithinMargin(15.45538167, cs.mPosVector[i].mLongitude, 0.000001); DoubleWithinMargin(70.562, cs.mAltVector[i], 0.000001); DoubleWithinMargin(18551, cs.mDistVector[i], 0.000001); Assert.AreEqual(TrainingSession.HRError, cs.mHRVector[i]); }
private string CyclingToString(CyclingSession s, string titel) { var finalString = titel + ":\n"; finalString += "Datum: " + s.When + "\n"; if (!(s.Distance == null)) { finalString += "Afstand: " + s.Distance + "km\n"; } finalString += "Tijd: " + s.Time + "\n"; if (!(s.AverageSpeed == null)) { finalString += "Gemidelde Snelheid: " + s.AverageSpeed + "\n"; } if (!(s.AverageWatt == null)) { finalString += "Gemodelde Watt: " + s.AverageWatt + "\n"; } finalString += "Training tipe: " + s.TrainingType + "\n"; if (!String.IsNullOrWhiteSpace(s.Comments)) { finalString += "Comentaar: " + s.Comments + "\n"; } finalString += "Fiets tipe: " + s.BikeType + "\n"; return(finalString); }
public CyclingSession[] FindMaxSessions() { CyclingSession[] rides = new CyclingSession[3]; rides[0] = context.CyclingSessions.OrderByDescending(s => s.Distance).ThenByDescending(s => s.AverageSpeed).First(); rides[1] = context.CyclingSessions.OrderByDescending(s => s.AverageSpeed).ThenByDescending(s => s.Distance).First(); rides[2] = context.CyclingSessions.OrderByDescending(s => s.AverageWatt).ThenByDescending(s => s.Time).First(); return(rides); }
public void CyclingSession_AverageSpeed_Calculated_WhenNotProvided() { float expected = 1.53846153846F; var actual = new CyclingSession(DateTime.Now.AddHours(-6.5), 10, TimeSpan.FromHours(6.5), null, 1, TrainingType.Endurance, "lalala", BikeType.IndoorBike).AverageSpeed; Should.Equals(expected, actual); }
public void CyclingSessionAverageSpeedTest() { //Arrange var runSes = new CyclingSession(new DateTime(1, 1, 1), 100, new TimeSpan(1, 0, 0), null, null, TrainingType.Interval, null, BikeType.IndoorBike); var expected = 100; //Assert runSes.AverageSpeed.Should().Equals(expected); }
public void GetPreviousCyclingSessionsTest() { TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContextTest(true))); CyclingSession cyclingSession1 = new CyclingSession(new DateTime(2020, 4, 18, 18, 00, 00), 40, new TimeSpan(1, 42, 00), null, null, TrainingType.Recuperation, null, BikeType.RacingBike); CyclingSession cyclingSession2 = new CyclingSession(new DateTime(2020, 4, 19, 16, 45, 00), null, new TimeSpan(1, 0, 00), null, 219, TrainingType.Interval, "5x5 min 270", BikeType.IndoorBike); cyclingSession1.Id = 2; //TM.GetPreviousCyclingSessions(1).ShouldBe(cyclingSession1); //TM.GetPreviousCyclingSessions(2).ShouldContain(cyclingSession2); }
public void CycleSes_AverageTimeTest() { CyclingSession testSession = new CyclingSession(new DateTime(2000, 02, 29), 30, new TimeSpan(3, 30, 0), null, 1, TrainingType.Interval, "This is a test", BikeType.IndoorBike); float expected = 30 / 3.5f; var result = testSession.AverageSpeed; result.Should().BeOfType(typeof(float)); result.Should().Be(expected); }
public void TestShouldAltBeUsed() { FileReader f = new FileReader(); string path = @"C:\own\programming\projects\TrainingAnalysisFull\TrainingAnalysisGUI\sessions\Petter_Stenhagen_2019-07-30_17-02-02.tcx"; string session = f.readFile(path); string startTime = TrainingSession.getHeaderInfo(session)["startTime"]; CyclingSession cs = new CyclingSession(startTime); bool success = cs.loadSessionBody(session); Calibration.ShouldAltBeUsed(cs); Assert.IsTrue(true); }
public OverviewData(CyclingSession cs) { colId = cs.Id; col0 = new BitmapImage(new Uri(@"..\..\cycling.png", UriKind.Relative)); col1 = OVTrainingType(cs.TrainingType); col2 = cs.When; col3 = OVkm(cs.Distance); col4 = OVTimeSpan(cs.Time); col5 = OVkmh(cs.AverageSpeed); col6 = OVWatt(cs.AverageWatt); col7 = OVBikeType(cs.BikeType); col8 = cs.Comments; }
public void TestCyclingSessionConstructor() { //Arrange = initialisatie objecten en kent waarden van gegevens toe aan methoden DateTime now = DateTime.Now; float distance = 400; TimeSpan time = new TimeSpan(0, 10, 20); float? averageSpeed = null; int averageWatt = 400; //Act = roept testen method op met ingestgelde parameters CyclingSession cs = new CyclingSession(now, distance, time, averageSpeed, averageWatt, TrainingType.Interval, "comment", BikeType.MountainBike); //Assert = verifieert actie van geteste methode cs.AverageSpeed.Should().Be(2322.5806f); }
public void TestAddCycling() { using (new TransactionScope()) { TrainingContextTest db = new TrainingContextTest(); var originalCount = db.CyclingSessions.ToList().Count(); CyclingSession x = new CyclingSession(new DateTime(2020, 4, 19, 16, 45, 00), null, new TimeSpan(1, 0, 00), null, 219, TrainingType.Interval, "5x5 min 270", BikeType.IndoorBike); db.CyclingSessions.Add(x); db.SaveChanges(); Assert.AreEqual(originalCount + 1, db.CyclingSessions.ToList().Count()); } }
public void TestAverageSpeedCalculation() { //Arrange DateTime date = DateTime.Now; float distance = 25; TimeSpan time = new TimeSpan(2, 0, 0); //act CyclingSession cs = new CyclingSession(date, distance, time, null, null, TrainingType.Endurance, "", BikeType.CityBike); float expectation = 12.5f; //Assert Assert.IsNotNull(cs.AverageSpeed, "No Attempt at a calculation was made"); Assert.AreEqual(cs.AverageSpeed, expectation, "AverageSpeed was not calculated correctly when not given"); }
public void TestNullAcceptanceForCyclingSessionTable() { //Arrange TrainingManager m = new TrainingManager(new UnitOfWork(new TrainingContextTest())); m.AddCyclingTraining(DateTime.Now, null, new TimeSpan(2, 0, 0), null, null, TrainingType.Endurance, null, BikeType.CityBike); //Act CyclingSession cyclingSession = m.GetPreviousCyclingSessions(1)[0]; //Assert Assert.IsNull(cyclingSession.AverageSpeed); Assert.IsNull(cyclingSession.Distance); Assert.IsNull(cyclingSession.AverageWatt); Assert.IsNull(cyclingSession.Comments); }
private void VullListBoxOP() { int _maand = int.Parse(maand.Text); int _jaar = int.Parse(jaar.Text); bool fiets = (bool)FietsTrainingcheck.IsChecked; bool loop = (bool)LoopTrainingcheck.IsChecked; listboxMaand.Items.Clear(); IDs.Clear(); if (fiets && loop) { foreach (var s in DC.GetMonlyReport(_jaar, _maand).TimeLine) { if (s.Item2 is CyclingSession) { CyclingSession tempCycl = (CyclingSession)s.Item2; listboxMaand.Items.Add(CyclingToString(tempCycl, "Fiets sessie")); IDs.Add(tempCycl.Id); } else { RunningSession tempCycl = (RunningSession)s.Item2; listboxMaand.Items.Add(RunnungToString(tempCycl, "Loop sessie")); IDs.Add(tempCycl.Id); } } } else if (fiets && !loop) { foreach (var s in DC.GetMonlyCyclingReport(_jaar, _maand).TimeLine) { CyclingSession tempCycl = (CyclingSession)s.Item2; listboxMaand.Items.Add(CyclingToString(tempCycl, "Fiets sessie")); IDs.Add(tempCycl.Id); } } else if (!fiets && loop) { foreach (var s in DC.GetMonlyRunningReport(_jaar, _maand).TimeLine) { RunningSession tempCycl = (RunningSession)s.Item2; listboxMaand.Items.Add(RunnungToString(tempCycl, "Loop sessie")); IDs.Add(tempCycl.Id); } } }
public void DomainController_GetMontlyCyclingReport_ReceivedCyclingReport() { DC.AddCyclingTraining(new DateTime(2020, 4, 21, 16, 00, 00), 40, new TimeSpan(1, 20, 00), 30, null, TrainingType.Endurance, null, BikeType.RacingBike); var montlycycling = DC.GetMonlyCyclingReport(2020, 4).TimeLine; CyclingSession tempCycle = (CyclingSession)montlycycling[0].Item2; tempCycle.When.Should().Be(_cycling.When); tempCycle.Distance.Should().Be(_cycling.Distance); tempCycle.Time.Should().Be(_cycling.Time); tempCycle.AverageSpeed.Should().Be(_cycling.AverageSpeed); tempCycle.AverageWatt.Should().Be(_cycling.AverageWatt); tempCycle.TrainingType.Should().Be(_cycling.TrainingType); tempCycle.Comments.Should().Be(_cycling.Comments); tempCycle.BikeType.Should().Be(_cycling.BikeType); }
public void ProductTest() { // Arrange using (new TransactionScope()) { TrainingContextTests db = new TrainingContextTests(); var originalCount = db.CyclingSessions.ToList().Count(); CyclingSession x = new CyclingSession(new DateTime(2020, 4, 21, 16, 00, 00), 40, new TimeSpan(1, 20, 00), 30, null, TrainingType.Endurance, null, BikeType.RacingBike); // Act db.CyclingSessions.Add(x); db.SaveChanges(); // Assert Assert.AreEqual(originalCount + 1, db.CyclingSessions.ToList().Count()); } }
private void btnRemoveCyclingSession_Click(object sender, RoutedEventArgs e) { CyclingSession toRemove = (CyclingSession)cyclingSessionBox.SelectedItem; List <int> toRemoveID = new List <int>() { toRemove.Id }; List <int> RunningSessions = new List <int>(); if (cyclingSessionBox.SelectedItem != null) { m.RemoveTrainings(toRemoveID, RunningSessions); MessageBox.Show($"{toRemove} is removed!", "CyclingSession", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show($"Nothing selected", "CyclingSession", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { TrainingManager m = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); if (CyclingRadioButton.IsChecked == true) { CyclingSession selectedItem = (CyclingSession)dgTraining.SelectedItem; m.RemoveTrainings(new List <int> { selectedItem.Id }, new List <int>()); } else { RunningSession selectedItem = (RunningSession)dgTraining.SelectedItem; m.RemoveTrainings(new List <int>(), new List <int> { selectedItem.Id }); } }
public void TestNullAcceptance() { //Arrange DateTime now = DateTime.Now; TimeSpan time = new TimeSpan(2, 3, 4); TrainingType training = TrainingType.Endurance; BikeType bike = BikeType.CityBike; //Act CyclingSession cyclingSession = new CyclingSession(now, null, time, null, null, training, null, bike); //Assert Assert.IsNull(cyclingSession.AverageSpeed, "AverageSpeed did not accept null"); Assert.IsNull(cyclingSession.Distance, "Distance did not accept null"); Assert.IsNull(cyclingSession.AverageWatt, "Wattage did not accept null"); Assert.IsNull(cyclingSession.Comments, "comments did not accept null"); Assert.IsNotNull(cyclingSession.When, "When was also made null"); Assert.IsNotNull(cyclingSession.Time, "Time was also made null"); Assert.IsNotNull(cyclingSession.TrainingType, "TrainingType was also made null"); Assert.IsNotNull(cyclingSession.BikeType, "BikeType was also made null"); }
public void DomainController_GetCountCycleSessions_ReceivedCycleSSessions() { //CyclingSession cycle2 = new CyclingSession(new DateTime(2020, 4, 18, 18, 00, 00), 40, new TimeSpan(1, 42, 00), null, null, TrainingType.Recuperation, null, BikeType.RacingBike); //CyclingSession cycle3 = new CyclingSession(new DateTime(2020, 4, 19, 16, 45, 00), null, new TimeSpan(1, 0, 00), null, 219, TrainingType.Interval, "5x5 min 270", BikeType.IndoorBike); DC.AddCyclingTraining(new DateTime(2020, 4, 21, 16, 00, 00), 40, new TimeSpan(1, 20, 00), 30, null, TrainingType.Endurance, null, BikeType.RacingBike); var count = DC.GetCountCyclingSessions(1); // if(montly[0].Item2 is CyclingSession) CyclingSession tempCycle = count[0]; tempCycle.When.Should().Be(_cycling.When); tempCycle.Distance.Should().Be(_cycling.Distance); tempCycle.Time.Should().Be(_cycling.Time); tempCycle.AverageSpeed.Should().Be(_cycling.AverageSpeed); tempCycle.AverageWatt.Should().Be(_cycling.AverageWatt); tempCycle.TrainingType.Should().Be(_cycling.TrainingType); tempCycle.Comments.Should().Be(_cycling.Comments); tempCycle.BikeType.Should().Be(_cycling.BikeType); }
public void TestAddCyclingSessionToDatabase() { //Arrange TrainingManager m = new TrainingManager(new UnitOfWork(new TrainingContextTest())); DateTime now = DateTime.Now; CyclingSession cS = new CyclingSession(now, 10, new TimeSpan(2, 0, 0), null, null, TrainingType.Endurance, "", BikeType.CityBike); //Act m.AddCyclingTraining(now, 10, new TimeSpan(2, 0, 0), null, null, TrainingType.Endurance, "", BikeType.CityBike); CyclingSession retrieved = m.GetPreviousCyclingSessions(1)[0]; //Assert Assert.IsTrue(m.GetAllCyclingSessions().Count == 1); Assert.IsTrue(m.GetAllRunningSessions().Count == 0, "Cycling Session got added as Running Session as well"); Assert.AreEqual(retrieved.AverageSpeed, cS.AverageSpeed, "AverageSpeed did not match up"); Assert.AreEqual(retrieved.AverageWatt, cS.AverageWatt, "AverageWatt did not match up"); Assert.AreEqual(retrieved.BikeType, cS.BikeType, "BikeType did not match up"); Assert.AreEqual(retrieved.Comments, cS.Comments, "Comments did not match up"); Assert.AreEqual(retrieved.Distance, cS.Distance, "Distance did not match up"); Assert.AreEqual(retrieved.Time, cS.Time, "Time did not match up"); Assert.AreEqual(retrieved.TrainingType, cS.TrainingType, "TrainingType did not match up"); Assert.AreEqual(retrieved.When, cS.When, "When did not match up"); }
public void TestMonthlyTotalReport() { //Arrange TrainingManager addingManager = new TrainingManager(new UnitOfWork(new TrainingContextTest())); DateTime fastestRideTime = new DateTime(2010, 4, 12); DateTime ignoredRideTime = new DateTime(2000, 2, 5); DateTime longestRideTime = new DateTime(2010, 4, 10); DateTime wattestRideTime = new DateTime(2005, 8, 6); DateTime fastestRunTime = new DateTime(2010, 4, 11); DateTime ignoredSessionTime = new DateTime(2000, 2, 4); DateTime longestRunTime = new DateTime(2010, 4, 15); CyclingSession fastestRide = new CyclingSession(fastestRideTime, 20, new TimeSpan(1, 0, 0), null, 30, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession secFastRide = new CyclingSession(ignoredRideTime, 20, new TimeSpan(5, 0, 0), null, 35, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession longestRide = new CyclingSession(longestRideTime, 25, new TimeSpan(10, 0, 0), null, 25, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession wattestRide = new CyclingSession(wattestRideTime, 10, new TimeSpan(1, 0, 0), null, 200, TrainingType.Endurance, null, BikeType.CityBike); RunningSession fastestRun = new RunningSession(fastestRunTime, 20000, new TimeSpan(1, 0, 0), null, TrainingType.Endurance, null); RunningSession secFastRun = new RunningSession(ignoredSessionTime, 20000, new TimeSpan(5, 0, 0), null, TrainingType.Endurance, null); RunningSession longestRun = new RunningSession(longestRunTime, 25000, new TimeSpan(10, 0, 0), null, TrainingType.Endurance, null); addingManager.AddCyclingTraining(fastestRide.When, fastestRide.Distance, fastestRide.Time, fastestRide.AverageSpeed, fastestRide.AverageWatt, fastestRide.TrainingType, fastestRide.Comments, fastestRide.BikeType); addingManager.AddCyclingTraining(secFastRide.When, secFastRide.Distance, secFastRide.Time, secFastRide.AverageSpeed, secFastRide.AverageWatt, secFastRide.TrainingType, secFastRide.Comments, secFastRide.BikeType); addingManager.AddCyclingTraining(longestRide.When, longestRide.Distance, longestRide.Time, longestRide.AverageSpeed, longestRide.AverageWatt, longestRide.TrainingType, longestRide.Comments, longestRide.BikeType); addingManager.AddCyclingTraining(wattestRide.When, wattestRide.Distance, wattestRide.Time, wattestRide.AverageSpeed, wattestRide.AverageWatt, wattestRide.TrainingType, wattestRide.Comments, wattestRide.BikeType); addingManager.AddRunningTraining(fastestRun.When, fastestRun.Distance, fastestRun.Time, fastestRun.AverageSpeed, fastestRun.TrainingType, fastestRun.Comments); addingManager.AddRunningTraining(secFastRun.When, secFastRun.Distance, secFastRun.Time, secFastRun.AverageSpeed, secFastRun.TrainingType, secFastRun.Comments); addingManager.AddRunningTraining(longestRun.When, longestRun.Distance, longestRun.Time, longestRun.AverageSpeed, longestRun.TrainingType, longestRun.Comments); DateTime secondRideTime = new DateTime(2010, 5, 10); DateTime firstRideTime = new DateTime(2010, 5, 1); DateTime thirdRideTime = new DateTime(2010, 5, 31); DateTime laterRideTime = new DateTime(2010, 6, 1); DateTime earlyRideTime = new DateTime(2010, 4, 30); DateTime secondRunTime = new DateTime(2010, 5, 11); DateTime firstRunTime = new DateTime(2010, 5, 2); DateTime thirdRunTime = new DateTime(2010, 5, 30); DateTime laterRunTime = new DateTime(2010, 6, 2); DateTime earlyRunTime = new DateTime(2010, 4, 29); CyclingSession secondRide = new CyclingSession(secondRideTime, 5, new TimeSpan(1, 0, 0), null, 10, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession firstRide = new CyclingSession(firstRideTime, 5, new TimeSpan(1, 0, 0), null, 50, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession thirdRide = new CyclingSession(thirdRideTime, 5, new TimeSpan(1, 0, 0), null, 30, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession laterRide = new CyclingSession(laterRideTime, 5, new TimeSpan(1, 0, 0), null, 20, TrainingType.Endurance, null, BikeType.CityBike); CyclingSession earlyRide = new CyclingSession(earlyRideTime, 5, new TimeSpan(1, 0, 0), null, 15, TrainingType.Endurance, null, BikeType.CityBike); RunningSession secondRun = new RunningSession(secondRunTime, 5000, new TimeSpan(1, 0, 0), null, TrainingType.Endurance, null); RunningSession firstRun = new RunningSession(firstRunTime, 5000, new TimeSpan(1, 0, 0), null, TrainingType.Endurance, null); RunningSession thirdRun = new RunningSession(thirdRunTime, 5000, new TimeSpan(1, 0, 0), null, TrainingType.Endurance, null); RunningSession laterRun = new RunningSession(laterRunTime, 5000, new TimeSpan(1, 0, 0), null, TrainingType.Endurance, null); RunningSession earlyRun = new RunningSession(earlyRunTime, 5000, new TimeSpan(1, 0, 0), null, TrainingType.Endurance, null); addingManager.AddCyclingTraining(secondRide.When, secondRide.Distance, secondRide.Time, secondRide.AverageSpeed, secondRide.AverageWatt, secondRide.TrainingType, secondRide.Comments, secondRide.BikeType); addingManager.AddCyclingTraining(firstRide.When, firstRide.Distance, firstRide.Time, firstRide.AverageSpeed, firstRide.AverageWatt, firstRide.TrainingType, firstRide.Comments, firstRide.BikeType); addingManager.AddCyclingTraining(thirdRide.When, thirdRide.Distance, thirdRide.Time, thirdRide.AverageSpeed, thirdRide.AverageWatt, thirdRide.TrainingType, thirdRide.Comments, thirdRide.BikeType); addingManager.AddCyclingTraining(laterRide.When, laterRide.Distance, laterRide.Time, laterRide.AverageSpeed, laterRide.AverageWatt, laterRide.TrainingType, laterRide.Comments, laterRide.BikeType); addingManager.AddCyclingTraining(earlyRide.When, earlyRide.Distance, earlyRide.Time, earlyRide.AverageSpeed, earlyRide.AverageWatt, earlyRide.TrainingType, earlyRide.Comments, earlyRide.BikeType); addingManager.AddRunningTraining(secondRun.When, secondRun.Distance, secondRun.Time, secondRun.AverageSpeed, secondRun.TrainingType, secondRun.Comments); addingManager.AddRunningTraining(firstRun.When, firstRun.Distance, firstRun.Time, firstRun.AverageSpeed, firstRun.TrainingType, firstRun.Comments); addingManager.AddRunningTraining(thirdRun.When, thirdRun.Distance, thirdRun.Time, thirdRun.AverageSpeed, thirdRun.TrainingType, thirdRun.Comments); addingManager.AddRunningTraining(laterRun.When, laterRun.Distance, laterRun.Time, laterRun.AverageSpeed, laterRun.TrainingType, laterRun.Comments); addingManager.AddRunningTraining(earlyRun.When, earlyRun.Distance, earlyRun.Time, earlyRun.AverageSpeed, earlyRun.TrainingType, earlyRun.Comments); //Act TrainingManager reportManager = new TrainingManager(new UnitOfWork(new TrainingContextTest(true))); int reportYear = 2010; int reportMonth = 5; Report report = reportManager.GenerateMonthlyTrainingsReport(reportYear, reportMonth); //Assert Assert.AreEqual(report.StartDate, new DateTime(reportYear, reportMonth, 1), "StartDate dit not match up"); Assert.AreEqual(report.EndDate, new DateTime(reportYear, reportMonth, DateTime.DaysInMonth(reportYear, reportMonth)), "EndDate did not match up"); Assert.AreEqual(report.RunningSessions, 3, "Number of RunningSessions was incorrect"); Assert.AreEqual(report.CyclingSessions, 3, "Number of CyclingSessions was incorrect"); Assert.AreEqual(report.TotalSessions, 6, "Number of TotalSessions was incorrect"); Assert.AreEqual(report.Rides[0].When, firstRideTime, "The first element in Rides did not match, probably not sorted by date properly"); Assert.AreEqual(report.Rides[1].When, secondRideTime, "The second element in Rides did not match"); Assert.AreEqual(report.Rides[2].When, thirdRideTime, "The third element in Rides did not match"); Assert.AreEqual(report.Runs[0].When, firstRunTime, "The first element in Runs did not match,probably not sorted by date properly"); Assert.AreEqual(report.Runs[1].When, secondRunTime, "The second element in Runs did not match"); Assert.AreEqual(report.Runs[2].When, thirdRunTime, "The third element in Runs did not match"); Assert.AreEqual(report.MaxDistanceSessionCycling.When, longestRideTime, "Max Distance Ride did not match up"); Assert.AreEqual(report.MaxSpeedSessionCycling.When, fastestRideTime, "Max Speed Ride did not match up"); Assert.AreEqual(report.MaxWattSessionCycling.When, wattestRideTime, "Max Watt Ride did not match up"); Assert.AreEqual(report.TotalCyclingDistance, secondRide.Distance + firstRide.Distance + thirdRide.Distance); Assert.AreEqual(report.TotalCyclingTrainingTime, secondRide.Time + firstRide.Time + thirdRide.Time); Assert.AreEqual(report.MaxDistanceSessionRunning.When, longestRunTime, "Max Distance Run did not match up"); Assert.AreEqual(report.MaxSpeedSessionRunning.When, fastestRunTime, "Max Speed Run did not match up"); Assert.AreEqual(report.TotalRunningDistance, secondRun.Distance + firstRun.Distance + thirdRun.Distance); Assert.AreEqual(report.TotalRunningTrainingTime, secondRun.Time + firstRun.Time + thirdRun.Time); Assert.AreEqual(report.TotalTrainingTime, report.TotalRunningTrainingTime + report.TotalCyclingTrainingTime, "TotalTrainingTime did not add up"); Assert.AreEqual(report.TimeLine[0].Item2, report.Rides[0], "Timeline did not match up"); Assert.AreEqual(report.TimeLine[0].Item1, SessionType.Cycling, "Type of first Item did not match up"); Assert.AreEqual(report.TimeLine[1].Item2, report.Runs[0], "Timeline did not match up"); Assert.AreEqual(report.TimeLine[1].Item1, SessionType.Running, "Type of second Item did not match up"); Assert.AreEqual(report.TimeLine[2].Item2, report.Rides[1], "Timeline did not match up"); Assert.AreEqual(report.TimeLine[2].Item1, SessionType.Cycling, "Type of third Item did not match up"); Assert.AreEqual(report.TimeLine[3].Item2, report.Runs[1], "Timeline did not match up"); Assert.AreEqual(report.TimeLine[3].Item1, SessionType.Running, "Type of fourth Item did not match up"); Assert.AreEqual(report.TimeLine[4].Item2, report.Runs[2], "Timeline did not match up"); Assert.AreEqual(report.TimeLine[4].Item1, SessionType.Running, "Type of fifth Item did not match up"); Assert.AreEqual(report.TimeLine[5].Item2, report.Rides[2], "Timeline did not match up"); Assert.AreEqual(report.TimeLine[5].Item1, SessionType.Cycling, "Type of sixth Item did not match up"); }
public void AddTraining(CyclingSession training) { context.CyclingSessions.Add(training); }
public void CyclingSession_AverageSpeedNullAndDistanceNotNull_CreatesCyclingSession() { CyclingSession cycle = new CyclingSession(new DateTime(2020, 4, 21, 16, 00, 00), 40, new TimeSpan(1, 20, 00), null, 20, TrainingType.Endurance, null, BikeType.RacingBike); cycle.AverageSpeed.Should().Be(30); }
public void CyclingSession_AverageWattNull_CreatesCyclingSession() { CyclingSession cycle = new CyclingSession(new DateTime(2020, 4, 21, 16, 00, 00), 40, new TimeSpan(1, 20, 00), 20, null, TrainingType.Endurance, null, BikeType.RacingBike); cycle.AverageWatt.Should().Be(null); }
private void besteTrainingOpVullen() { bool fiets = false; try { fiets = (bool)radioFiets.IsChecked; } catch (Exception) { } besteTrainingen.Items.Clear(); //loop langste afstand , gemiddelde snelheid EN gemiddelde snelheid //fiets langste afstand , gemiddelde snelheid EN gemiddelde snelheid if (fiets) { List <CyclingSession> CyckingList = DC.GetAllCyclingSessions(); CyclingSession topDistance = CyckingList[0]; foreach (CyclingSession c in CyckingList) { if (topDistance.Distance <= c.Distance) { if ((topDistance.Distance == c.Distance) && (topDistance.AverageSpeed < c.AverageSpeed)) { topDistance = c; } if (topDistance.Distance < c.Distance) { topDistance = c; } } } besteTrainingen.Items.Add(CyclingToString(topDistance, "Fiets sessie met meeste afstand")); CyclingSession topSpeed = CyckingList[0]; foreach (CyclingSession c in CyckingList) { if (topSpeed.AverageSpeed <= c.AverageSpeed) { topSpeed = c; } } besteTrainingen.Items.Add(CyclingToString(topSpeed, "Hoogste gemidelde snelheid")); } else { List <RunningSession> CyckingList = DC.GetAllRunningSessions(); RunningSession topDistance = CyckingList[0]; foreach (RunningSession c in CyckingList) { if (topDistance.Distance <= c.Distance) { if ((topDistance.Distance == c.Distance) && (topDistance.AverageSpeed < c.AverageSpeed)) { topDistance = c; } if (topDistance.Distance < c.Distance) { topDistance = c; } } } besteTrainingen.Items.Add(RunnungToString(topDistance, "Loop sessie met meeste afstand")); RunningSession topSpeed = CyckingList[0]; foreach (RunningSession c in CyckingList) { if (topSpeed.AverageSpeed <= c.AverageSpeed) { topSpeed = c; } } besteTrainingen.Items.Add(RunnungToString(topSpeed, "Hoogste gemidelde snelheid")); } //besteTrainingen.Items.Add(CyclingToString(c)); }