Esempio n. 1
0
        public void TestLoadSessionBodyRunning()
        {
            // Reading a training session file and checking that the first and last produced datapoints are registered
            // correctly in a TrainingSession.

            FileReader     f         = new FileReader();
            string         session   = f.readFile("C:\\own\\programming\\projects\\TrainingAnalysis\\csharp\\TrainingAnalysis\\TrainingAnalysis\\running_full.tcx");
            string         startTime = TrainingSession.getHeaderInfo(session)["startTime"];
            RunningSession ts        = new RunningSession(startTime);
            bool           success   = ts.loadSessionBody(session);

            Assert.IsTrue(success);
            Assert.AreEqual(2756, ts.mTimeVector.Count);

            // First
            Assert.AreEqual(0, ts.mTimeVector[0]);
            DoubleWithinMargin(58.40579, ts.mPosVector[0].mLatitude, 0.000001);
            DoubleWithinMargin(15.61054333, ts.mPosVector[0].mLongitude, 0.000001);
            DoubleWithinMargin(95.251, ts.mAltVector[0], 0.000001);
            DoubleWithinMargin(3.5, ts.mDistVector[0], 0.000001);
            Assert.AreEqual(124, ts.mHRVector[0]);

            // Last
            Assert.AreEqual(2755, ts.mTimeVector[2755]);
            DoubleWithinMargin(58.40277333, ts.mPosVector[2755].mLatitude, 0.000001);
            DoubleWithinMargin(15.61368, ts.mPosVector[2755].mLongitude, 0.000001);
            DoubleWithinMargin(68.886, ts.mAltVector[2755], 0.000001);
            DoubleWithinMargin(11815.2001953125, ts.mDistVector[2755], 0.000001);
            Assert.AreEqual(166, ts.mHRVector[2755]);
        }
Esempio n. 2
0
 public RunningSession[] FindMaxSessions()
 {
     RunningSession[] runs = new RunningSession[2];
     runs[0] = context.RunningSessions.OrderByDescending(s => s.Distance).ThenByDescending(s => s.AverageSpeed).First();
     runs[1] = context.RunningSessions.OrderByDescending(s => s.AverageSpeed).ThenByDescending(s => s.Distance).First();
     return(runs);
 }
        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 btnRemoveRunningSession_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         RunningSession toRemove   = (RunningSession)runninsSessionBox.SelectedItem;
         List <int>     toRemoveID = new List <int>()
         {
             toRemove.Id
         };
         List <int> CyclingSession = new List <int>();
         if (runninsSessionBox.SelectedItem != null)
         {
             m.RemoveTrainings(CyclingSession, toRemoveID);
             MessageBox.Show($"{toRemove} is removed!", "RunningSession", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             MessageBox.Show($"Nothing selected", "RunningSession", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Running session", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 5
0
        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;
        }
            protected override TestResults EndSessionInternal(RunningSession runningSession, bool isAborted, bool save)
            {
                TestResults result = base.EndSessionInternal(runningSession, isAborted, save);

                events_?.AfterEndSession?.Invoke();
                return(result);
            }
        public void TestRetryWhenServerConcurrencyLimitReached()
        {
            Configuration config = new Configuration();

            config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7));

            ConfigurationProvider configurationProvider = new ConfigurationProvider(config);
            VisualGridRunner      runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(3));
            VisualGridEyes        eyes   = new VisualGridEyes(configurationProvider, runner);

            eyes.SetLogHandler(TestUtils.InitLogHandler());

            int  counter            = 0;
            bool wasConcurrencyFull = false;

            eyes.EyesConnectorFactory = new MockEyesConnectorFactory()
            {
                Events = new Events()
                {
                    BeforeStartSession = () =>
                    {
                        if (Interlocked.Increment(ref counter) < 4)
                        {
                            RunningSession newSession = new RunningSession();
                            newSession.ConcurrencyFull = true;
                            return(newSession);
                        }
                        return(null);
                    }
                }
            };

            eyes.AfterServerConcurrencyLimitReachedQueried += (concurrecnyReached) =>
            {
                if (concurrecnyReached)
                {
                    wasConcurrencyFull = true;
                }
            };

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "http://applitools.github.io/demo";
            try
            {
                eyes.Open(driver, "Eyes SDK", "UFG Runner Concurrency", new Size(800, 800));
                eyes.Check(Target.Window().Fully());
                eyes.CloseAsync(true);
            }
            finally
            {
                eyes.AbortAsync();
                driver.Quit();
                runner.GetAllTestResults(false);
            }

            Assert.IsTrue(wasConcurrencyFull);
            Assert.IsFalse(((IVisualGridEyes)eyes).IsServerConcurrencyLimitReached());
            Assert.AreEqual(4, counter);
        }
Esempio n. 8
0
 private void CreateSessionBlocksFromSession(RunningSession session)
 {
     SessionBlocks.Clear();
     for (int i = 0; i < session.Sets; i++)
     {
         for (int j = 0; j < session.Reps; j++)
         {
             SessionBlocks.Add(new SessionBlock
             {
                 Time = session.RepTimeSpan,
                 Type = BlockType.Run,
                 Set  = i + 1,
                 Rep  = j + 1
             });
             if (j != session.Reps - 1)
             {
                 SessionBlocks.Add(new SessionBlock
                 {
                     Time = session.RepInterval,
                     Type = BlockType.Rest,
                     Set  = i + 1,
                     Rep  = j + 1
                 });
             }
         }
         SessionBlocks.Add(new SessionBlock
         {
             Time = session.SetInterval,
             Type = BlockType.Rest
         });
     }
 }
Esempio n. 9
0
        public void TestRemovingRunningSessionFromDatabase()
        {
            //Arrange
            TrainingManager m                      = new TrainingManager(new UnitOfWork(new TrainingContextTest()));
            DateTime        now                    = DateTime.Now;
            RunningSession  runSession             = new RunningSession(now, 10000, new TimeSpan(2, 0, 0), null, TrainingType.Endurance, "");
            RunningSession  toDeleteRunningSession = new RunningSession(new DateTime(2010, 5, 12), 10000, new TimeSpan(2, 0, 0), null, TrainingType.Endurance, null);

            m.AddRunningTraining(toDeleteRunningSession.When, toDeleteRunningSession.Distance, toDeleteRunningSession.Time, toDeleteRunningSession.AverageSpeed, toDeleteRunningSession.TrainingType, toDeleteRunningSession.Comments);
            m.AddRunningTraining(runSession.When, runSession.Distance, runSession.Time, runSession.AverageSpeed, runSession.TrainingType, runSession.Comments);
            TrainingManager m2 = new TrainingManager(new UnitOfWork(new TrainingContextTest(true)));

            //Act
            m2.RemoveTrainings(new List <int>(), new List <int> {
                1
            });
            var            runningSessions = m.GetAllRunningSessions();
            RunningSession retrievedRun    = runningSessions[0];

            //Assert
            Assert.IsTrue(runningSessions.Count == 1, "The Running Session was not deleted");
            Assert.AreEqual(retrievedRun.AverageSpeed, runSession.AverageSpeed, "AverageSpeed did not match up");
            Assert.AreEqual(retrievedRun.Comments, runSession.Comments, "Comments did not match up");
            Assert.AreEqual(retrievedRun.Distance, runSession.Distance, "Distance did not match up");
            Assert.AreEqual(retrievedRun.Time, runSession.Time, "Time did not match up");
            Assert.AreEqual(retrievedRun.TrainingType, runSession.TrainingType, "TrainingType did not match up");
            Assert.AreEqual(retrievedRun.When, runSession.When, "When did not match up");
        }
Esempio n. 10
0
        protected override void StartSessionInternal(TaskListener <RunningSession> taskListener, SessionStartInfo sessionStartInfo)
        {
            Logger.Log(TraceLevel.Info, Stage.Open, StageType.Called, new { sessionStartInfo });

            RunningSession newSession         = null;
            bool           continueInvocation = true;
            bool           callBase           = false;

            if (continueInvocation)
            {
                newSession = new RunningSession()
                {
                    isNewSession_ = false, SessionId = Guid.NewGuid().ToString()
                };
                SessionIds.Add(newSession.SessionId);
                Sessions.Add(newSession.SessionId, newSession);
                SessionsStartInfo.Add(newSession.SessionId, sessionStartInfo);
            }
            if (callBase)
            {
                base.StartSessionInternal(taskListener, sessionStartInfo);
            }
            else
            {
                EnsureHttpClient_();
                taskListener.OnComplete(newSession);
            }
        }
Esempio n. 11
0
        public void RunningSession_AverageSpeed_Calculated_WhenNotProvided()
        {
            float expected = 1.53846153846F;

            var actual = new RunningSession(DateTime.Now.AddHours(-6.5), 10000, TimeSpan.FromHours(6.5), null, TrainingType.Endurance, "lalala").AverageSpeed;

            Should.Equals(expected, actual);
        }
Esempio n. 12
0
        public void RunningSessionTestAverageSpeedTest()
        {
            //Arrange
            var runSes   = new RunningSession(new DateTime(1, 1, 1), 100, new TimeSpan(1, 0, 0), null, TrainingType.Interval, null);
            var expected = 100;

            //Assert
            runSes.AverageSpeed.Should().Equals(expected);
        }
            protected override RunningSession StartSessionInternal(SessionStartInfo startInfo)
            {
                RunningSession result = events_?.BeforeStartSession?.Invoke();

                if (result == null)
                {
                    result = base.StartSessionInternal(startInfo);
                }
                return(result);
            }
Esempio n. 14
0
        public void RunSes_AverageTimeTest()
        {
            RunningSession testSession = new RunningSession(new DateTime(2000, 02, 29), 30000, new TimeSpan(3, 30, 0), null, TrainingType.Interval, "This is a test");

            float expected = (30000 / 1000) / 3.5f;

            var result = testSession.AverageSpeed;

            result.Should().BeOfType(typeof(float));
            result.Should().Be(expected);
        }
Esempio n. 15
0
        public void GetPreviousRunningSessionsTest()
        {
            TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContextTest(true)));
            RunningSession  runningSession1 = new RunningSession(new DateTime(2020, 3, 17, 11, 0, 00), 5000, new TimeSpan(0, 28, 10), null, TrainingType.Interval, "3x700m");
            RunningSession  runningSession2 = new RunningSession(new DateTime(2020, 3, 17, 11, 0, 00), 8000, new TimeSpan(0, 42, 10), null, TrainingType.Endurance, null);

            List <RunningSession> runningsessions = TM.GetPreviousRunningSessions(2);

            runningsessions[0].ShouldBe(runningSession1);
            runningsessions[1].ShouldBe(runningSession2);
        }
 public OverviewData(RunningSession rs)
 {
     colId = rs.Id;
     col0  = new BitmapImage(new Uri(@"..\..\running.png", UriKind.Relative));
     col1  = OVTrainingType(rs.TrainingType);
     col2  = rs.When;
     col3  = OVm(rs.Distance);
     col4  = OVTimeSpan(rs.Time);
     col5  = OVkmh(rs.AverageSpeed);
     col6  = "";
     col7  = "";
     col8  = rs.Comments;
 }
Esempio n. 17
0
        public void AddTrainingTest()
        {
            //Arrange
            SetRepoAndContext();
            var runSes    = new RunningSession(new DateTime(2020, 4, 19, 12, 30, 00), 5000, new TimeSpan(0, 25, 48), null, TrainingType.Endurance, null);
            int initCount = _context.RunningSessions.Count();

            //Act
            _runRepo.AddTraining(runSes);
            _context.SaveChanges();
            //Assert
            Assert.AreEqual(initCount + 1, _context.RunningSessions.Count());
        }
        public void TestRunningSessionConstructor()
        {
            //Arrange = initialisatie objecten en kent waarden van gegevens toe aan methoden
            DateTime now          = DateTime.Now;
            int      distance     = 4000;
            TimeSpan time         = new TimeSpan(0, 10, 20);
            float?   averageSpeed = null;
            //Act = roept testen method op met ingestgelde parameters
            RunningSession rs = new RunningSession(now, distance, time, averageSpeed, TrainingType.Endurance, "comment");

            //Assert = verifieert actie van geteste methoden
            rs.AverageSpeed.Should().Be(23.225807F);
        }
Esempio n. 19
0
        public void TestNullAcceptanceForRunningSessionTable()
        {
            //Arrange
            TrainingManager m = new TrainingManager(new UnitOfWork(new TrainingContextTest()));

            m.AddRunningTraining(DateTime.Now, 15000, new TimeSpan(2, 0, 0), null, TrainingType.Endurance, null);

            //Act
            RunningSession runningSession = m.GetPreviousRunningSessions(1)[0];

            //Assert
            Assert.IsNull(runningSession.Comments);
        }
Esempio n. 20
0
        public RunningSession StartSession(SessionStartInfo sessionStartInfo)
        {
            logger_.Log("starting session: {0}", sessionStartInfo);

            var newSession = new RunningSession()
            {
                isNewSession_ = false, SessionId = Guid.NewGuid().ToString()
            };

            SessionIds.Add(newSession.SessionId);
            Sessions.Add(newSession.SessionId, newSession);
            SessionsStartInfo.Add(newSession.SessionId, sessionStartInfo);
            return(newSession);
        }
        public void DomainController_GetMontlyRunningReport_ReceivedRunningReport()
        {
            DC.AddRunningTraining(new DateTime(2020, 4, 17, 12, 30, 00), 5000, new TimeSpan(0, 27, 17), null, TrainingType.Endurance, null);

            var montlyRunning = DC.GetMonlyRunningReport(2020, 4).TimeLine;

            RunningSession tempRunn = (RunningSession)montlyRunning[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);
        }
Esempio n. 22
0
        public void FindTest()
        {
            //Arrange
            SetRepoAndContext();
            var runSes = new RunningSession(new DateTime(2020, 4, 19, 12, 30, 00), 5000, new TimeSpan(0, 25, 48), null, TrainingType.Endurance, null);

            _runRepo.AddTraining(runSes);
            _context.SaveChanges();

            //Act
            var actual = _runRepo.Find(1);

            //Assert
            actual.Should().Equals(runSes);
        }
        public void TestAddTraining()
        {
            using (new TransactionScope())
            {
                TrainingContextTest db       = new TrainingContextTest();
                var            originalCount = db.RunningSessions.ToList().Count();
                RunningSession x             = new RunningSession(new DateTime(2000, 2, 17, 12, 30, 00), 5000, new TimeSpan(0, 27, 17), null, TrainingType.Endurance, null);

                db.RunningSessions.Add(x);
                db.SaveChanges();


                Assert.AreEqual(originalCount + 1, db.RunningSessions.ToList().Count());
            }
        }
Esempio n. 24
0
 public MatchResult MatchWindow(RunningSession runningSession, MatchWindowData data)
 {
     if (data.Options.ReplaceLast)
     {
         ReplaceMatchedStepCalls.Add(data);
     }
     else
     {
         MatchWindowCalls.Add(data);
     }
     return(new MatchResult()
     {
         AsExpected = this.AsExcepted
     });
 }
Esempio n. 25
0
        public void TestRemovingMixedSessionFromDatabase()
        {
            //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);
            RunningSession  runSession             = new RunningSession(now, 10000, new TimeSpan(2, 0, 0), null, TrainingType.Endurance, "");
            RunningSession  toDeleteRunningSession = new RunningSession(new DateTime(2010, 5, 12), 10000, new TimeSpan(2, 0, 0), null, TrainingType.Endurance, null);

            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);
            m.AddRunningTraining(toDeleteRunningSession.When, toDeleteRunningSession.Distance, toDeleteRunningSession.Time, toDeleteRunningSession.AverageSpeed, toDeleteRunningSession.TrainingType, toDeleteRunningSession.Comments);
            m.AddRunningTraining(runSession.When, runSession.Distance, runSession.Time, runSession.AverageSpeed, runSession.TrainingType, runSession.Comments);
            TrainingManager m2 = new TrainingManager(new UnitOfWork(new TrainingContextTest(true)));

            //Act
            m2.RemoveTrainings(new List <int>()
            {
                1
            }, new List <int>()
            {
                1
            });
            var            cyclingSessions = m2.GetAllCyclingSessions();
            var            runningSessions = m.GetAllRunningSessions();
            CyclingSession RetrievedCycle  = cyclingSessions[0];
            RunningSession retrievedRun    = runningSessions[0];

            //Assert
            Assert.IsTrue(cyclingSessions.Count == 1, "The Running Session was not deleted");
            Assert.IsTrue(runningSessions.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");

            Assert.AreEqual(retrievedRun.AverageSpeed, runSession.AverageSpeed, "AverageSpeed did not match up");
            Assert.AreEqual(retrievedRun.Comments, runSession.Comments, "Comments did not match up");
            Assert.AreEqual(retrievedRun.Distance, runSession.Distance, "Distance did not match up");
            Assert.AreEqual(retrievedRun.Time, runSession.Time, "Time did not match up");
            Assert.AreEqual(retrievedRun.TrainingType, runSession.TrainingType, "TrainingType did not match up");
            Assert.AreEqual(retrievedRun.When, runSession.When, "When did not match up");
        }
        public void DomainController_GetCountRunningSessions_ReceivedRunningSessions()
        {
            DC.AddRunningTraining(new DateTime(2020, 4, 17, 12, 30, 00), 5000, new TimeSpan(0, 27, 17), null, TrainingType.Endurance, null);

            var count = DC.GetCountRunningSessions(1);

            // if(montly[0].Item2 is CyclingSession)
            RunningSession tempRunn = count[0];

            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);
        }
Esempio n. 27
0
        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 TestNullAverageSpeed_ShouldBeCalculatedAtCreation()
        {
            //Arrange
            DateTime     now      = DateTime.Now;
            int          distance = 21000;
            TimeSpan     time     = new TimeSpan(2, 0, 0);
            float?       speed    = null;
            TrainingType training = TrainingType.Endurance;
            string       comment  = null;

            //Act
            RunningSession runningSession = new RunningSession(now, distance, time, speed, training, comment);
            float          expectation    = 10.5f;

            //Assert
            Assert.IsNotNull(runningSession.AverageSpeed, "No attempt at a calculation was made");
            Assert.AreEqual(expectation, runningSession.AverageSpeed, "AverageSpeed was not calculated correctly");
        }
Esempio n. 29
0
        private string RunnungToString(RunningSession s, string titel)
        {
            var finalString = titel + "\n";

            finalString += "Datum: " + s.When + "\n";
            finalString += "Afstand: " + s.Distance + "m\n";
            finalString += "Tijd: " + s.Time + "\n";
            if (!(s.AverageSpeed == 0))
            {
                finalString += "Gemidelde Snelheid: " + s.AverageSpeed + "\n";
            }
            finalString += "Training tipe: " + s.TrainingType + "\n";
            if (!String.IsNullOrWhiteSpace(s.Comments))
            {
                finalString += "Comentaar: " + s.Comments + "\n";
            }
            return(finalString);
        }
Esempio n. 30
0
        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
                });
            }
        }