public void TestUpdateMaintenanceWorkOrderValidDescription() { //Arrange MaintenanceWorkOrder newMaintenanceWorkOrder = new MaintenanceWorkOrder(); setMaintenanceWorkOrders(_maintenanceWorkOrders[0], newMaintenanceWorkOrder); string newDescription = "This test is updating the description in TestUpdateMaintenanceWorkOrderValidDescription()"; newMaintenanceWorkOrder.Description = newDescription; //Act _maintenanceWorkOrderManager.EditMaintenanceWorkOrder(_maintenanceWorkOrders[0], newMaintenanceWorkOrder); //Assert _maintenanceWorkOrders = _maintenanceWorkOrderManager.RetrieveAllMaintenanceWorkOrders(); Assert.AreEqual(_maintenanceWorkOrderManager.RetrieveMaintenanceWorkOrder(_maintenanceWorkOrders[0].MaintenanceWorkOrderID).Description, newDescription); }
/// <summary> /// Author: Dalton Cleveland /// Created : 1/31/2019 /// The function which runs when Save is clicked /// </summary> private void btnSave_Click(object sender, RoutedEventArgs e) { if (((string)btnSave.Content) == "Submit") { if (!ValidateInput()) { return; } MaintenanceWorkOrder newMaintenanceWorkOrder = new MaintenanceWorkOrder(); newMaintenanceWorkOrder.MaintenanceTypeID = (cboMaintenanceTypeID.SelectedItem.ToString()); newMaintenanceWorkOrder.DateRequested = DateTime.Now; newMaintenanceWorkOrder.RequestingEmployeeID = int.Parse(txtRequestingEmployeeID.Text); newMaintenanceWorkOrder.WorkingEmployeeID = int.Parse(txtWorkingEmployeeID.Text); newMaintenanceWorkOrder.ResortPropertyID = int.Parse(txtResortPropertyID.Text); newMaintenanceWorkOrder.MaintenanceStatusID = cboStatus.SelectedItem.ToString(); newMaintenanceWorkOrder.Comments = txtComments.Text; newMaintenanceWorkOrder.Description = txtDescription.Text; try { if (_existingMaintenanceWorkOrder == null) { _maintenanceWorkOrderManager.AddMaintenanceWorkOrder(newMaintenanceWorkOrder); SetError(""); MessageBox.Show("Maintenance Work Order Created Successfully: " + "\nMaintenanceTypeID: " + newMaintenanceWorkOrder.MaintenanceTypeID + "\nRequestingEmployeeID: " + newMaintenanceWorkOrder.RequestingEmployeeID + "\nWorkingEmployeeID: " + newMaintenanceWorkOrder.WorkingEmployeeID + "\nResortPropertyID: " + newMaintenanceWorkOrder.ResortPropertyID + "\nMaintenanceStatus: " + newMaintenanceWorkOrder.MaintenanceStatusID + "\nDescription: " + newMaintenanceWorkOrder.Description); } else { newMaintenanceWorkOrder.Complete = (bool)chkComplete.IsChecked; _maintenanceWorkOrderManager.EditMaintenanceWorkOrder(_existingMaintenanceWorkOrder, newMaintenanceWorkOrder); newMaintenanceWorkOrder.DateCompleted = DateTime.Now; SetError(""); MessageBox.Show("Maintenance Work Order Updated Successfully: " + "\nOld MaintenanceTypeID: " + _existingMaintenanceWorkOrder.MaintenanceTypeID + "\nOld DateRequested: " + _existingMaintenanceWorkOrder.DateRequested + "\nOld RequestingEmployeeID: " + _existingMaintenanceWorkOrder.RequestingEmployeeID + "\nOld WorkingEmployeeID: " + _existingMaintenanceWorkOrder.WorkingEmployeeID + "\nOld ResortPropertyID: " + _existingMaintenanceWorkOrder.ResortPropertyID + "\nOldMaintenanceStatusID: " + _existingMaintenanceWorkOrder.MaintenanceStatusID + "\nOld Description: " + _existingMaintenanceWorkOrder.Description + "\n" + "\nNew MaintenanceTypeID: " + newMaintenanceWorkOrder.MaintenanceTypeID + "\nNew DateCompleted: " + newMaintenanceWorkOrder.DateCompleted + "\nNew RequestingEmployeeID: " + newMaintenanceWorkOrder.RequestingEmployeeID + "\nNew WorkingEmployeeID: " + newMaintenanceWorkOrder.WorkingEmployeeID + "\nNew ResortPropertyID: " + newMaintenanceWorkOrder.ResortPropertyID + "\nNew MaintenanceStatusID: " + newMaintenanceWorkOrder.MaintenanceStatusID + "\nNew Comments: " + newMaintenanceWorkOrder.Comments + "\nNew Description: " + newMaintenanceWorkOrder.Description); } } catch (Exception ex) { SetError(ex.Message); } Close(); } else if (((string)btnSave.Content) == "Update") { setEditable(); } else { MessageBox.Show(btnSave.Content.GetType() + " " + btnSave.Content); } }