public void ObservableListExtensions_All_ReturnsTrueIfObservableListIsEmpty() { var list = new ObservableList<Int32>(); var result = list.All(x => x % 2 == 0); TheResultingValue(result).ShouldBe(true); }
public void ObservableListExtensions_All_ReturnsTrueIfAllItemsMatchPredicate() { var list = new ObservableList<Int32>() { 2, 4, 6 }; var result = list.All(x => x % 2 == 0); TheResultingValue(result).ShouldBe(true); }
public void ObservableListExtensions_All_ReturnsFalseIfOneItemDoesNotMatchPredicate() { var list = new ObservableList<Int32>() { 1, 2, 4, 6 }; var result = list.All(x => x % 2 == 0); TheResultingValue(result).ShouldBe(false); }
public void ObservableListExtensions_All_ReturnsTrueIfObservableListIsEmpty() { var list = new ObservableList <Int32>(); var result = list.All(x => x % 2 == 0); TheResultingValue(result).ShouldBe(true); }
public void ObservableListExtensions_All_ReturnsFalseIfOneItemDoesNotMatchPredicate() { var list = new ObservableList <Int32>() { 1, 2, 4, 6 }; var result = list.All(x => x % 2 == 0); TheResultingValue(result).ShouldBe(false); }
public void ObservableListExtensions_All_ReturnsTrueIfAllItemsMatchPredicate() { var list = new ObservableList <Int32>() { 2, 4, 6 }; var result = list.All(x => x % 2 == 0); TheResultingValue(result).ShouldBe(true); }
private void btnConvertAction_Click(object sender, RoutedEventArgs e) { // Check if no actions are selected to be converted if (lstActionToBeConverted.All(act => act.Selected == false)) { Reporter.ToUser(eUserMsgKey.NoConvertibleActionSelected); return; } if (!DoExistingPlatformCheck(lstActionToBeConverted)) { //missing target application so stop the conversion return; } else { try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; // setting the conversion status label as visible lblConversionStatus.Visibility = Visibility.Visible; Reporter.ToStatus(eStatusMsgKey.BusinessFlowConversion, null, mBusinessFlow.Name); // create a new converted activity if ((bool)radNewActivity.IsChecked) { Activity newActivity = new Activity() { Active = true }; foreach (Activity oldActivity in mBusinessFlow.Activities.ToList()) { // check if the activity is selected for conversion and it contains actions that are obsolete (of type, IObsolete) if (oldActivity.SelectedForConversion && oldActivity.Acts.OfType <IObsoleteAction>().ToList().Count > 0) { newActivity = (Activity)oldActivity.CreateCopy(false); newActivity.ActivityName = "New - " + oldActivity.ActivityName; mBusinessFlow.Activities.Add(newActivity); mBusinessFlow.Activities.Move(mBusinessFlow.Activities.Count() - 1, mBusinessFlow.Activities.IndexOf(oldActivity) + 1); foreach (Act oldAct in oldActivity.Acts.ToList()) { if (oldAct is IObsoleteAction && lstActionToBeConverted.Where(act => act.SourceActionType == oldAct.GetType() && act.Selected && act.TargetActionType == ((IObsoleteAction)oldAct).TargetAction()).FirstOrDefault() != null) { // convert the old action Act newAct = ((IObsoleteAction)oldAct).GetNewAction(); int oldActionIndex = newActivity.Acts.IndexOf(newActivity.Acts.Where(x => x.Guid == oldAct.Guid).FirstOrDefault()); newActivity.Acts.RemoveAt(oldActionIndex); newActivity.Acts.Add(newAct); newActivity.Acts.Move(newActivity.Acts.Count() - 1, oldActionIndex); } } // check if the old activity was active or not and accordingly set Active field for the new activity if (!oldActivity.Active) { newActivity.Active = false; } else { newActivity.Active = true; } // by default, set the old activity as inactive oldActivity.Active = false; // if the user has not chosen any target application in the combobox then, we set it as empty if ((Boolean)chkDefaultTargetApp.IsChecked && cmbTargetApp.SelectedIndex != -1) { newActivity.TargetApplication = cmbTargetApp.SelectedValue.ToString(); } else { newActivity.TargetApplication = string.Empty; } } } } else { foreach (Activity activity in mBusinessFlow.Activities) { if (activity.SelectedForConversion && activity.Acts.OfType <IObsoleteAction>().ToList().Count > 0) { foreach (Act act in activity.Acts.ToList()) { if (act.Active && act is IObsoleteAction && lstActionToBeConverted.Where(a => a.SourceActionType == act.GetType() && a.Selected && a.TargetActionType == ((IObsoleteAction)act).TargetAction()).FirstOrDefault() != null) { // get the index of the action that is being converted int selectedActIndex = activity.Acts.IndexOf(act); // convert the old action activity.Acts.Add(((IObsoleteAction)act).GetNewAction()); if (selectedActIndex >= 0) { activity.Acts.Move(activity.Acts.Count - 1, selectedActIndex + 1); } // set obsolete action in the activity as inactive act.Active = false; } } // if the user has not chosen any target application in the combobox then, we set it as empty if ((Boolean)chkDefaultTargetApp.IsChecked && cmbTargetApp.SelectedIndex != -1) { activity.TargetApplication = cmbTargetApp.SelectedValue.ToString(); } else { activity.TargetApplication = string.Empty; } } } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to convert " + GingerDicser.GetTermResValue(eTermResKey.Activities) + " - ", ex); Reporter.ToUser(eUserMsgKey.ActivitiesConversionFailed); } finally { Mouse.OverrideCursor = null; } } lblConversionStatus.Visibility = Visibility.Hidden; Reporter.HideStatusMessage(); // ask the user if he wants to convert more actions once the conversion is done successfully if (Reporter.ToUser(eUserMsgKey.SuccessfulConversionDone) == Amdocs.Ginger.Common.eUserMsgSelection.No) { _pageGenericWin.Close(); } }