public void AddRunningTrainingTest() { TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContextTest(true))); var runningCount = TM.GetAllRunningSessions().Count(); runningCount.ShouldBe(4); TM.AddRunningTraining(new DateTime(2020, 3, 17, 11, 0, 00), 8000, new TimeSpan(0, 42, 10), null, TrainingType.Endurance, null); runningCount = TM.GetAllRunningSessions().Count(); runningCount.ShouldBe(5); }
public AddTrainingPage() { InitializeComponent(); manager = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); CountTotal.Text = "" + (manager.GetAllRunningSessions().Count + manager.GetAllCyclingSessions().Count); CountRunning.Text = "" + manager.GetAllRunningSessions().Count; CountCycling.Text = "" + manager.GetAllCyclingSessions().Count; InputBikeType.Visibility = Visibility.Collapsed; InputBikeTypeLabel.Visibility = Visibility.Collapsed; }
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"); }
public static List <OverviewData> GetAllRunningData() { List <OverviewData> datas = new List <OverviewData>(); TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContext())); TM.GetAllRunningSessions().ForEach(x => datas.Add(new OverviewData(x))); return(datas); }
private void DataDeleteAllClickEvent(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure you want to remove all items?", "Configuration", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { TrainingManager manager = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); dataTable.Clear(); List <int> runningIDs = manager.GetAllRunningSessions().Select(x => x.Id).ToList(); List <int> cyclingIDs = manager.GetAllCyclingSessions().Select(x => x.Id).ToList(); manager.RemoveTrainings(cyclingIDs, runningIDs); } }
public void RemoveTrainingsTest() { TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContextTest(true))); TM.RemoveTrainings(new List <int> { 1 }, new List <int> { 2, 3, 4 }); TM.GetAllRunningSessions().Count.ShouldBe(1); TM.GetAllCyclingSessions().Count.ShouldBe(2); }
public RapportR(TrainingManager t) { InitializeComponent(); this.training = t; this.training = t; List <RunningSession> rTraining = training.GetAllRunningSessions(); foreach (var rt in rTraining) { output.Text += rt.ToString() + "\n"; } }
private void DeleteAll_click(object sender, RoutedEventArgs e) { TrainingManager manager = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); Dt.Clear(); Dt2.Clear(); List <int> runningIDs = manager.GetAllRunningSessions().Select(x => x.Id).ToList(); List <int> cyclingIDs = manager.GetAllCyclingSessions().Select(x => x.Id).ToList(); TrainingManager manager2 = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); manager2.RemoveTrainings(cyclingIDs, runningIDs); }
public DashboardPage() { InitializeComponent(); ShowsNavigationUI = false; // Setup table dataTable = new DataTable(); dataTable.Clear(); dataTable.Columns.Add(new DataColumn("Id", typeof(int))); dataTable.Columns.Add(new DataColumn("Sport", typeof(string))); dataTable.Columns.Add(new DataColumn("Type", typeof(string))); dataTable.Columns.Add(new DataColumn("Distance", typeof(string))); dataTable.Columns.Add(new DataColumn("Duration", typeof(string))); dataTable.Columns.Add(new DataColumn("Av Speed", typeof(string))); dataTable.Columns.Add(new DataColumn("Av Watt", typeof(string))); dataTable.Columns.Add(new DataColumn("Bike Type", typeof(string))); dataTable.Columns.Add(new DataColumn("Date", typeof(DateTime))); dataTable.Columns.Add(new DataColumn("Comment", typeof(string))); DataTable.ItemsSource = dataTable.DefaultView; TrainingManager manager = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); CountTotal.Text = "" + (manager.GetAllCyclingSessions().Count + manager.GetAllRunningSessions().Count); CountRunning.Text = "" + manager.GetAllRunningSessions().Count; CountCycling.Text = "" + manager.GetAllCyclingSessions().Count; foreach (RunningSession session in manager.GetAllRunningSessions()) { addDataLine(session.Id, "Running", session.TrainingType.ToString(), session.Distance.ToString() + " m", session.Time.ToString(), Math.Round(session.AverageSpeed, 2) + " km/h", "", "", session.When, session.Comments); } foreach (CyclingSession session in manager.GetAllCyclingSessions()) { addDataLine(session.Id, "Cycling", session.TrainingType.ToString(), session.Distance.ToString() + " km", session.Time.ToString(), Math.Round(Convert.ToDecimal(session.AverageSpeed), 2) + " km/h", session.AverageWatt + "", session.BikeType.ToString(), session.When, session.Comments); } }
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 RemoveTraining_ShouldExecute() { var expectedSingle = 2; var expectedMultiple = 2; TM = new TrainingManager(new UnitOfWork(new TrainingContextTest(true))); TM.RemoveTrainings(new List <int>() { 1 }, new List <int>() { 2, 3 }); TM.GetAllCyclingSessions().Count.ShouldBe(expectedSingle); TM.GetAllRunningSessions().Count.ShouldBe(expectedMultiple); }
public void TestMultipleAdditionsAndGetAllCyclingSessions() { //Arrange TrainingManager m = new TrainingManager(new UnitOfWork(new TrainingContextTest())); int totalAdded = 0; //Act for (int i = 0; i < 1000; i++) { m.AddCyclingTraining(DateTime.Now, 10, new TimeSpan(1, 0, 0), null, null, TrainingType.Recuperation, null, BikeType.CityBike); totalAdded++; } var collection = m.GetAllCyclingSessions(); //Assert Assert.IsTrue(collection.Count == totalAdded); Assert.IsTrue(m.GetAllRunningSessions().Count == 0, "There were Running Sessions added"); }
public void AllRunningSessionTests() { TrainingManager tm = new TrainingManager(new UnitOfWork(new TrainingContextTest(false))); tm.AddRunningTraining(new DateTime(2019, 10, 1), 350, new TimeSpan(2, 50, 0), 25, TrainingType.Interval, "number 1"); tm.AddRunningTraining(new DateTime(2019, 10, 2), 300, new TimeSpan(2, 30, 0), 20, TrainingType.Endurance, "number 2"); tm.AddRunningTraining(new DateTime(2019, 10, 3), 150, new TimeSpan(2, 40, 0), 30, TrainingType.Interval, "number 3"); tm.AddRunningTraining(new DateTime(2018, 10, 1), 200, new TimeSpan(2, 30, 0), 20, TrainingType.Endurance, "number 4"); DateTime session0Date = new DateTime(2018, 10, 1); int session0Distance = 200; TimeSpan session0Time = new TimeSpan(2, 30, 0); float session0AveSpeed = 20; TrainingType session0TrainType = TrainingType.Endurance; string session0Comment = "number 4"; DateTime session3Date = new DateTime(2019, 10, 3); int session3Distance = 150; TimeSpan session3Time = new TimeSpan(2, 40, 0); float session3AveSpeed = 30; TrainingType session3TrainType = TrainingType.Interval; string session3Comment = "number 3"; int nrOfSessions = 4; List <RunningSession> runningSessions = tm.GetAllRunningSessions(); runningSessions.Count.Should().Be(nrOfSessions); runningSessions[3].When.Should().Be(session3Date); runningSessions[3].Distance.Should().Be(session3Distance); runningSessions[3].Time.Should().Be(session3Time); runningSessions[3].AverageSpeed.Should().Be(session3AveSpeed); runningSessions[3].TrainingType.Should().Be(session3TrainType); runningSessions[3].Comments.Should().BeEquivalentTo(session3Comment); runningSessions[0].When.Should().Be(session0Date); runningSessions[0].Distance.Should().Be(session0Distance); runningSessions[0].Time.Should().Be(session0Time); runningSessions[0].AverageSpeed.Should().Be(session0AveSpeed); runningSessions[0].TrainingType.Should().Be(session0TrainType); runningSessions[0].Comments.Should().BeEquivalentTo(session0Comment); }
public void TestAddRunningSessionToDatabase() { //Arrange TrainingManager m = new TrainingManager(new UnitOfWork(new TrainingContextTest())); DateTime now = DateTime.Now; RunningSession cS = new RunningSession(now, 10000, new TimeSpan(2, 0, 0), null, TrainingType.Endurance, ""); //Act m.AddRunningTraining(now, 10000, new TimeSpan(2, 0, 0), null, TrainingType.Endurance, ""); RunningSession retrieved = m.GetPreviousRunningSessions(1)[0]; //Assert Assert.IsTrue(m.GetAllRunningSessions().Count == 1); Assert.IsTrue(m.GetAllCyclingSessions().Count == 0, "Running Session got added as Cycling Session as well"); Assert.AreEqual(retrieved.AverageSpeed, cS.AverageSpeed, "AverageSpeed 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 GetAllRunningSessionsTest() { TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContextTest(true))); TM.GetAllRunningSessions().Count().ShouldBe(4); }
public void RefreshRunningSessions() { runninsSessionBox.ItemsSource = m.GetAllRunningSessions(); }
public RunningSessionWindow(TrainingManager trainingmg) { InitializeComponent(); m = trainingmg; runninsSessionBox.ItemsSource = m.GetAllRunningSessions(); }
private void LoadTrDATA_Load(object sender, RoutedEventArgs e) { Dt = new DataTable(); Dt2 = new DataTable(); Dt.Columns.Add(new DataColumn("ID", typeof(int))); Dt.Columns.Add(new DataColumn("Start", typeof(DateTime))); Dt.Columns.Add(new DataColumn("Distance in KM", typeof(int))); Dt.Columns.Add(new DataColumn("Duration", typeof(TimeSpan))); Dt.Columns.Add(new DataColumn("Speed", typeof(int))); Dt.Columns.Add(new DataColumn("Comment", typeof(String))); Dt.Columns.Add(new DataColumn("Type", typeof(int))); Dt.Columns.Add(new DataColumn("Watt", typeof(String))); Dt.Columns.Add(new DataColumn("Bicycle", typeof(String))); Dt2.Columns.Add(new DataColumn("ID", typeof(int))); Dt2.Columns.Add(new DataColumn("Start", typeof(DateTime))); Dt2.Columns.Add(new DataColumn("Distance In M", typeof(int))); Dt2.Columns.Add(new DataColumn("Duration", typeof(TimeSpan))); Dt2.Columns.Add(new DataColumn("Speed", typeof(int))); Dt2.Columns.Add(new DataColumn("Comment", typeof(String))); Dt2.Columns.Add(new DataColumn("Type", typeof(int))); foreach (var item in m.GetAllCyclingSessions()) { DataRow x = Dt.NewRow(); if (item.Distance == null) { x[2] = 0; } else { x[2] = item.Distance; } if (item.AverageWatt == null) { x[7] = "N/A"; } else { x[7] = item.AverageWatt.ToString(); } if (item.AverageSpeed == null) { x[4] = 0; } else { x[4] = item.AverageSpeed; } x[0] = item.Id; x[1] = item.When; x[3] = item.Time; x[5] = item.Comments; x[6] = item.TrainingType; x[8] = item.BikeType.ToString(); Dt.Rows.Add(x); } foreach (var item in m.GetAllRunningSessions()) { DataRow x = Dt2.NewRow(); if (item.Distance == null) { x[2] = 0; } else { x[2] = item.Distance; } if (item.AverageSpeed == null) { x[4] = 0; } else { x[4] = item.AverageSpeed; } x[0] = item.Id; x[1] = item.When; x[3] = item.Time; x[5] = item.Comments; x[6] = item.TrainingType; Dt2.Rows.Add(x); } DtaGrid2.ItemsSource = Dt2.DefaultView; TrainingGrid_Overview.ItemsSource = Dt.DefaultView; }
public List <RunningSession> GetAllRunningSessions() { return(_gerry.GetAllRunningSessions()); }
private static RunningSession GetBestRunningSession() { TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContext())); return(TM.GetAllRunningSessions().OrderBy(x => x.Distance).LastOrDefault()); }