private bool DisplayNameMatch(UtItemViewModel itemViewModel, string text) { if (String.IsNullOrEmpty(text) || String.IsNullOrEmpty(itemViewModel.DisplayName)) { return(false); } return(itemViewModel.DisplayName.IndexOf(text, StringComparison.InvariantCultureIgnoreCase) > -1); }
public UtTreeViewModel(UtItem root) { myTreeRoot = new UtItemViewModel(root) { IsExpanded = true }; myUtProjects = new ReadOnlyCollection <UtItemViewModel>(new[] { myTreeRoot }); mySearchCommand = new SearchTreeCommand(this); }
private UtItemViewModel(UtItem item, UtItemViewModel parent) { myItem = item; myParent = parent; myChildren = new ReadOnlyCollection <UtItemViewModel>( (from child in myItem.Children select new UtItemViewModel(child, this)) .ToList <UtItemViewModel>()); myRunTestCommand = new RunTestCommand(this); }
private IEnumerable <UtItemViewModel> FindMatches(string searchText, UtItemViewModel utItemViewModel) { if (DisplayNameMatch(utItemViewModel, searchText)) { yield return(utItemViewModel); } foreach (UtItemViewModel child in utItemViewModel.Children) { foreach (UtItemViewModel match in FindMatches(searchText, child)) { yield return(match); } } }
private void ExecuteTestRecusively(UtItemViewModel vm) { if (vm.ItemType == ItemType.TestMethod || vm.ItemType == ItemType.TestCaseMethod) { var instance = vm.Parent.ClassInstance; var methodInfo = vm.TestMethod; var arguments = vm.InnerItem.Arguments; var setupMethod = vm.InnerItem.SetUpMethod; var teardownMethod = vm.InnerItem.TearDownMethod; try { if (setupMethod != null) { setupMethod.Invoke(instance, null); } methodInfo.Invoke(instance, arguments); if (teardownMethod != null) { teardownMethod.Invoke(instance, null); } vm.TestPassed = TestResult.Passed; } catch (Exception e) { vm.TestPassed = TestResult.Failed; vm.FailedStackTrace = e.InnerException.StackTrace; } } foreach (var child in vm.Children) { ExecuteTestRecusively(child); } }
public RunTestCommand(UtItemViewModel utItemViewModel) { myUtItemViewModel = utItemViewModel; }