Esempio n. 1
0
        /// <summary>
        /// William Clark
        /// Created: 2021/03/04
        ///
        /// Updates the current routine in the data store, then udpates the interface to reflect the changes
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        private void btnSaveRoutineDescription_Click(object sender, RoutedEventArgs e)
        {
            Routine newRoutine = new Routine(txtRoutineName.Text, txtRoutineDescription.Text, _routine.UserAccountID_Client, _routine.UserAccountID_Admin, _routine.Active, _routine.EntryDate, DateTime.Now, null);

            try
            {
                if (_routineManager.UpdateRoutine(_routine, newRoutine))
                {
                    try
                    {
                        _routine = new RoutineVM(newRoutine, _routineManager.GetRoutineStepsByRoutine(newRoutine));
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("The Steps of the routine could not be loaded.");
                    }
                }
                else
                {
                    MessageBox.Show("The Routine could not be updated.");
                }
                PopulatePage();
            }
            catch (Exception)
            {
                MessageBox.Show("The routine could not be updated.");
            }
        }
        public void TestUpdateRoutineReturnsBool()
        {
            // Arrange
            bool expectedResult = true;
            bool actualResult;

            // Act
            actualResult = _routineManager.UpdateRoutine(arbitraryValidRoutine, new Routine("FirstRoutine", "A change has been made", new DateTime(2021, 2, 26), 3, 1, false));

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }