예제 #1
0
        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);
        }
예제 #2
0
        public UtTreeViewModel(UtItem root)
        {
            myTreeRoot = new UtItemViewModel(root)
            {
                IsExpanded = true
            };

            myUtProjects = new ReadOnlyCollection <UtItemViewModel>(new[] { myTreeRoot });

            mySearchCommand = new SearchTreeCommand(this);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
 public RunTestCommand(UtItemViewModel utItemViewModel)
 {
     myUtItemViewModel = utItemViewModel;
 }