public void TestSelectCompletedSetupListsValid()
        {
            // Arrange: Create a valid Setup Lists that's "complete"
            // as well as an incomplete one.
            SetupList testSetupList1 = new SetupList()
            {
                // SetupList ID is generated by the database.
                SetupID     = 100000,
                Completed   = true,
                Description = "Test valid",
                Comments    = "Test Valid"
            };

            SetupList testSetupList2 = new SetupList()
            {
                // SetupList ID is generated by the database.
                SetupID     = 100000,
                Completed   = false,
                Description = "Test valid",
                Comments    = "Test Valid"
            };

            _setupListManager.InsertSetupList(testSetupList1);
            _setupListManager.InsertSetupList(testSetupList2);


            // Act: Retrieve the list of setups from the Mock Accessor.
            _setupLists = _setupListManager.SelectAllSetupLists();

            // Assert: Try to find each of the Setups in the _setups list.
            Assert.IsNotNull(_setupLists.Find(x => x.SetupID == testSetupList1.SetupID &&
                                              x.Completed == testSetupList1.Completed &&
                                              x.Description == testSetupList1.Description &&
                                              x.Comments == testSetupList1.Comments));
        }
        public void TestSelectCompletedSetupListsValidNoComplete()
        {
            // Arrange: Create two incomplete setup lists.
            SetupList testSetupList1 = new SetupList()
            {
                // SetupList ID is generated by the database.
                SetupID     = 100000,
                Completed   = false,
                Description = "Test valid",
                Comments    = "Test Valid"
            };

            SetupList testSetupList2 = new SetupList()
            {
                // SetupList ID is generated by the database.
                SetupID     = 100000,
                Completed   = false,
                Description = "Test valid",
                Comments    = "Test Valid"
            };

            _setupListManager.InsertSetupList(testSetupList1);
            _setupListManager.InsertSetupList(testSetupList2);


            // Act: Retrieve the list of setups from the Mock Accessor.
            _setupLists = _setupListManager.SelectAllSetupLists();

            // Assert: Try to find each of the Setups in the _setups list.
            Assert.IsNull(_setupLists.Find(x => x.Completed == true));
        }
        /// <summary>
        /// Author: Caitlin Abelson
        /// Created Date: 2/28/19
        ///
        /// This method updates the setup list.
        /// </summary>
        /// <param name="newSetupList">The new object to be created.</param>
        /// <param name="oldSetupList">The old object to be read.</param>
        public int UpdateSetupList(SetupList newSetupList, SetupList oldSetupList)
        {
            int result = 0;

            var conn    = DBConnection.GetDbConnection();
            var cmdText = @"sp_update_setupList_by_id";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@SetupListID", oldSetupList.SetupListID);
            cmd.Parameters.AddWithValue("@Completed", newSetupList.Completed);
            cmd.Parameters.AddWithValue("@Description", newSetupList.Description);
            cmd.Parameters.AddWithValue("@Comments", newSetupList.Comments);
            cmd.Parameters.AddWithValue("@OldCompleted", oldSetupList.Completed);
            cmd.Parameters.AddWithValue("@OldDescription", oldSetupList.Description);
            cmd.Parameters.AddWithValue("@OldComments", oldSetupList.Comments);

            try
            {
                conn.Open();

                result = cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(result);
        }
        /// <summary>
        /// Author: Caitlin Abelson
        /// Created Date: 2/28/19
        ///
        /// The accessor method that creates a new setup list.
        /// </summary>
        /// <param name="newSetupList">The object that is being passed in to be created</param>
        /// <returns></returns>
        public void InsertSetupList(SetupList newSetupList)
        {
            //int result = 0;

            var conn    = DBConnection.GetDbConnection();
            var cmdText = @"sp_insert_SetupList";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@SetupID", newSetupList.SetupID);
            cmd.Parameters.AddWithValue("@Completed", newSetupList.Completed);
            cmd.Parameters.AddWithValue("@Description", newSetupList.Description);
            cmd.Parameters.AddWithValue("@Comments", newSetupList.Comments);

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            //return result;
        }
        public void TestDeleteSetupList()
        {
            // Arrange.
            SetupList setupList = new SetupList()
            {
                // SetupListID is generated by the database.
                SetupID     = 100000,
                Completed   = false,
                Description = "test test",
                Comments    = "Test Valid Setup"
            };

            _setupListManager.InsertSetupList(setupList);

            int setupListID = _setupListManager.SelectAllActiveSetupLists().Find(x =>
                                                                                 x.SetupID == setupList.SetupID &&
                                                                                 x.Completed == setupList.Completed &&
                                                                                 x.Description == setupList.Description &&
                                                                                 x.Comments == setupList.Comments).SetupListID;

            // Deactivate the setup.
            _setupListManager.DeleteSetupList(setupListID, true);

            // Act: Delete the setup.
            _setupListManager.DeleteSetupList(setupListID, false);

            // Assert: The Setup no longer exists; attempting to retrieve it will return null.
            Assert.IsNull(_setupListManager.SelectSetupList(setupListID));
        }
        private void BtnViewSetupList_Click(object sender, RoutedEventArgs e)
        {
            SetupList chosenSetupList = new SetupList();

            chosenSetupList = _setupListManager.SelectSetupList(((VMSetupList)dgSetupList.SelectedItem).SetupListID);
            var readSetupList = new SetupListDetail(chosenSetupList, ((VMSetupList)dgSetupList.SelectedItem).EventTitle);

            readSetupList.ShowDialog();
        }
        /// <summary>
        /// Eduardo
        ///
        /// Create a new mock setupList.
        /// </summary>
        /// <param name="newSetup"></param>
        /// <returns></returns>
        public void InsertSetupList(SetupList newSetupList)
        {
            newSetupList.SetupListID = _setupListID;
            _setupListID++;

            _setupLists.Add(newSetupList);

            //return newSetupList.SetupListID;
        }
예제 #8
0
 /// <summary author="Caitlin Abelson" created="2019/02/28">
 /// </summary>
 /// <param name="newSetupList">The object that the new SetupList is being created to</param>
 /// <returns></returns>
 public void InsertSetupList(SetupList newSetupList)
 {
     try
     {
         _setupListAccessor.InsertSetupList(newSetupList);
     }
     catch (Exception ex)
     {
         ExceptionLogManager.getInstance().LogException(ex);
         throw ex;
     }
 }
예제 #9
0
 /// <summary author="Caitlin Abelson" created="2019/02/28">
 /// </summary>
 /// <param name="newSetupList"></param>
 /// <param name="oldSetupList"></param>
 public void UpdateSetupList(SetupList newSetupList, SetupList oldSetupList)
 {
     try
     {
         _setupListAccessor.UpdateSetupList(newSetupList, oldSetupList);
     }
     catch (Exception ex)
     {
         ExceptionLogManager.getInstance().LogException(ex);
         throw ex;
     }
 }
        public void UpdateSetupListValid()
        {
            SetupList actualSetupList = null;

            // Create the original Setup Object.
            SetupList originalSetupList = new SetupList()
            {
                // SetupListID is generated by the database.
                SetupID     = 100000,
                Description = "Test Description",
                Completed   = true,
                Comments    = "Test Valid SetupList"
            };

            // Create the new Setup Object.
            SetupList expectedSetupList = new SetupList()
            {
                // SetupListID is generated by the database.
                SetupID     = 100000,
                Description = "Test Descriptions",
                Completed   = false,
                Comments    = "Test Valid SetupLists"
            };

            // Get the setupID generated for the original Setup and assign it to the
            // Setup we will update with.
            _setupListManager.InsertSetupList(originalSetupList);
            int setupListID = _setupListManager.SelectAllSetupLists().Find(x => x.SetupID == originalSetupList.SetupID &&
                                                                           x.Description == originalSetupList.Description &&
                                                                           x.Completed == originalSetupList.Completed &&
                                                                           x.Comments == originalSetupList.Comments).SetupListID;

            expectedSetupList.SetupID = setupListID;


            // Act: Update the Setup.
            _setupListManager.UpdateSetupList(expectedSetupList, originalSetupList);

            // Assert: Retrieve the Setup with the same ID from the list
            // and compare it to the expectedSetup to see if the changes stuck.
            actualSetupList = _setupListManager.SelectSetupList(setupListID);


            Assert.IsTrue(expectedSetupList.SetupID == actualSetupList.SetupID &&
                          expectedSetupList.Description == actualSetupList.Description &&
                          expectedSetupList.Completed == actualSetupList.Completed &&
                          expectedSetupList.Comments == actualSetupList.Comments);
        }
        /// <summary>
        /// Author: Caitlin Abelson
        /// Created Date: 3/5/19
        ///
        /// The constructor for updating a SetupList
        /// </summary>
        public SetupListDetail(SetupList setupList, string eventName)
        {
            InitializeComponent();

            _setupListManager = new SetupListManager();
            _setupManager     = new SetupManager();
            _eventManager     = new LogicLayer.EventManager();


            _oldSetupList = setupList;
            _eventName    = eventName;

            txtEventName.Text = eventName;

            readOnlyForm();
        }
        /// <summary>
        /// Author James Heim
        /// Created 2019-03-15
        ///
        /// Update the specified SetupList by overwriting it with the new SetupList.
        /// Throw an exception if the IDs of both SetupLists do not match.
        /// </summary>
        /// <param name="newSetupList"></param>
        /// <param name="oldSetupList"></param>
        public int UpdateSetupList(SetupList newSetupList, SetupList oldSetupList)
        {
            int rows = 0;

            if (newSetupList.SetupListID == oldSetupList.SetupListID)
            {
                _setupLists.Remove(_setupLists.Find(x => x.SetupListID == oldSetupList.SetupListID));
                _setupLists.Add(newSetupList);
                rows = 1;
            }
            else
            {
                throw new Exception("ID of old SetupList and new SetupList do not match.");
            }

            return(rows);
        }
        private void BtnUpdateSetupList_Click(object sender, RoutedEventArgs e)
        {
            SetupList chosenSetupList = new SetupList();


            try
            {
                chosenSetupList = _setupListManager.SelectSetupList(((VMSetupList)dgSetupList.SelectedItem).SetupListID);
                var readSetupList = new SetupListDetail(chosenSetupList, ((VMSetupList)dgSetupList.SelectedItem).EventTitle);
                readSetupList.ShowDialog();
                refreshAllSetupLists();
                populateSetupLists();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to find selected setup list.\n" + ex.Message);
            }
        }
        public void TestSelectAllSetupLists()
        {
            // Arrange: Create valid test Setup Lists and add them to
            // the "database."
            SetupList testSetupList1 = new SetupList()
            {
                // SetupList ID is generated by the database.
                SetupID     = 100000,
                Completed   = false,
                Description = "Test valid",
                Comments    = "Test Valid"
            };

            SetupList testSetupList2 = new SetupList()
            {
                // SetupList ID is generated by the database.
                SetupID     = 100000,
                Completed   = false,
                Description = "Test valid",
                Comments    = "Test Valid"
            };

            _setupListManager.InsertSetupList(testSetupList1);
            _setupListManager.InsertSetupList(testSetupList2);


            // Act: Retrieve the list of setups from the Mock Accessor.
            _setupLists = _setupListManager.SelectAllSetupLists();

            // Assert: Try to find each of the Setups in the _setups list.
            // If we don't get a null exception, then they've both been found.
            _setupLists.Find(x => x.SetupID == testSetupList1.SetupID &&
                             x.Completed == testSetupList1.Completed &&
                             x.Description == testSetupList1.Description &&
                             x.Comments == testSetupList1.Comments);

            _setupLists.Find(x => x.SetupID == testSetupList2.SetupID &&
                             x.Completed == testSetupList2.Completed &&
                             x.Description == testSetupList2.Description &&
                             x.Comments == testSetupList2.Comments);
        }
        public void TestInsertSetupListValid()
        {
            // Arrange.
            SetupList expectedSetupList = null;

            // Create the new Setup Object.
            SetupList testSetupList = new SetupList()
            {
                // SetupListID is generated by the database.
                SetupID     = 100002,
                Completed   = false,
                Description = "test test",
                Comments    = "Test Valid SetupList"
            };


            // Act.

            // Add the Setup and pull up a fresh list of the setups.
            _setupListManager.InsertSetupList(testSetupList);
            _setupLists = _setupListManager.SelectAllSetupLists();

            // Attempt to retrieve the newly created Setup.
            expectedSetupList = _setupLists.Find(x => x.SetupID == testSetupList.SetupID &&
                                                 x.Completed == testSetupList.Completed &&
                                                 x.Description == testSetupList.Description &&
                                                 x.Comments == testSetupList.Comments);

            // Assert.

            // If we got this far without getting a NullArgumentException,
            // test if the setup we retrieved is identical to the one we created,
            // one property at a time.
            Assert.IsTrue
            (
                expectedSetupList.SetupID == testSetupList.SetupID &&
                expectedSetupList.Completed == testSetupList.Completed &&
                expectedSetupList.Description == testSetupList.Description &&
                expectedSetupList.Comments == testSetupList.Comments
            );
        }
        //Eduardo
        /// <summary>
        /// Updated By: Caitilin Abelson
        /// Date: 2019-03-14
        ///
        /// reader.Read() was not called making the method not able to read through rows of data.
        /// Added reader.Read()
        /// </summary>
        /// <param name="setupListID"></param>
        /// <returns></returns>
        public SetupList SelectSetupList(int setupListID)
        {
            SetupList setupList = new SetupList();
            var       cmdText   = @"sp_select_setuplist_by_id";
            var       conn      = DBConnection.GetDbConnection();

            var cmd = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@SetupListID", setupListID);
            try
            {
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    while (reader.HasRows)
                    {
                        setupList.SetupListID = reader.GetInt32(0);
                        setupList.SetupID     = reader.GetInt32(1);
                        setupList.Completed   = reader.GetBoolean(2);
                        setupList.Description = reader.GetString(3);
                        setupList.Comments    = reader.GetString(4);
                        break;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(setupList);
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (btnSave.Content.Equals("Submit"))
            {
                if (!ValidateInput())
                {
                    return;
                }

                _newSetupList = new SetupList();
                if (_oldSetupList == null)
                {
                    _newSetupList.SetupID     = _setup.SetupID;
                    _newSetupList.Description = txtDescription.Text;
                    _newSetupList.Comments    = txtComments.Text;
                }
                else
                {
                    _newSetupList.SetupListID = _oldSetupList.SetupListID;
                    _newSetupList.SetupID     = _oldSetupList.SetupID;
                    _newSetupList.Completed   = cbxCompleted.IsChecked.Value;
                    _newSetupList.Description = txtDescription.Text;
                    _newSetupList.Comments    = txtComments.Text;
                }

                try
                {
                    if (_oldSetupList == null)
                    {
                        _setupListManager.InsertSetupList(_newSetupList);

                        MessageBox.Show("SetupList Created: " +
                                        "\nEvent Name: " + _eventName +
                                        "\nDescription: " + _newSetupList.Description +
                                        "\nComments: " + _newSetupList.Comments);
                    }
                    else
                    {
                        _setupListManager.UpdateSetupList(_newSetupList, _oldSetupList);
                        SetError("");
                        MessageBox.Show("Setup List Update Successful: " +
                                        "\nEvent Name: " + _eventName +
                                        "\n" +
                                        "\nNew Completed: " + _newSetupList.Completed +
                                        "\nNew Description: " + _newSetupList.Description +
                                        "\nNew Comments: " + _newSetupList.Comments +
                                        "\n" +
                                        "\nOld Completed: " + _oldSetupList.Completed +
                                        "\nOld Description: " + _oldSetupList.Description +
                                        "\nOld Comments: " + _oldSetupList.Comments);
                    }
                }

                catch (Exception ex)
                {
                    SetError(ex.Message);
                }

                Close();
            }
            else if (btnSave.Content.Equals("Update"))
            {
                editForm();
            }
        }