public void SearchItemsViewModelTests_Search_EmptyFilter_NoSearchResults()
        {
            var viewModel = new SearchItemsViewModel("");

            viewModel.SearchAsync().Wait();

            Assert.AreEqual(0, viewModel.SearchItems.Count(), "Searching for empty string should return nothing.");
        }
        public void SearchItemsViewModelTests_Search_DoubleQuoteFilter_Success()
        {
            var viewModel = new SearchItemsViewModel("_\"\"_DoubleQuote_" + _quotesGuid);

            ValidateSearch(viewModel, new List <BaseEntity> {
                _storyDoubleQuote
            });
        }
        public void SearchItemsViewModelTests_Search_Filter_Success()
        {
            var viewModel = new SearchItemsViewModel(_guid.ToString());

            ValidateSearch(viewModel, new List <BaseEntity> {
                _story, _epic, _gherkinTest
            });

            Assert.AreEqual(WindowMode.Loaded, viewModel.Mode, "Mismatched window mode");
            Assert.AreEqual(null, viewModel.ErrorMessage, "Mismatched error message");
        }
        public void SearchItemsViewModelTests_Refresh_NoChanges_SameResults()
        {
            var viewModel = new SearchItemsViewModel(_guid.ToString());

            ValidateSearch(viewModel, new List <BaseEntity> {
                _story, _epic, _gherkinTest
            });

            viewModel.RefreshCommand.Execute(null);
            ValidateSearch(viewModel, new List <BaseEntity> {
                _story, _epic, _gherkinTest
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Search for the given filter
        /// </summary>
        internal void Search(string searchFilter)
        {
            if (string.IsNullOrEmpty(searchFilter) || string.IsNullOrEmpty(searchFilter.Trim()))
            {
                Caption = "\"\"";
                return;
            }

            searchFilter = searchFilter.Trim();

            Caption = $"\"{searchFilter}\"";
            if (searchFilter.Length > 20)
            {
                Caption = $"\"{searchFilter.Substring(0, 20)}...\"";
            }

            var viewModel = new SearchItemsViewModel(searchFilter);

            viewModel.SearchAsync();
            _searchControl.DataContext = viewModel;
        }
        private static void ValidateSearch(SearchItemsViewModel viewModel, List <BaseEntity> expectedEntities)
        {
            Utility.WaitUntil(() =>
            {
                viewModel.SearchAsync().Wait();

                if (viewModel.SearchItems.Count() != expectedEntities.Count)
                {
                    return(false);
                }

                foreach (var entity in expectedEntities)
                {
                    if (viewModel.SearchItems.Count(si => si.ID == entity.Id && si.Entity.Name == entity.Name) != 1)
                    {
                        return(false);
                    }
                }

                return(true);
            }, "Timeout waiting for correct search results", new TimeSpan(0, 2, 0), new TimeSpan(0, 0, 1));
        }
        public void SearchItemsViewModelTests_Refresh_Changes_Success()
        {
            var viewModel = new SearchItemsViewModel(_refreshGuid.ToString());

            ValidateSearch(viewModel, new List <BaseEntity> {
                _refreshStory, _refreshEpic, _refreshGherkinTest
            });

            var newEpic = EpicUtilities.CreateEpic("Epic2_" + _refreshGuid);

            try
            {
                viewModel.RefreshCommand.Execute(null);
                ValidateSearch(viewModel, new List <BaseEntity> {
                    _refreshStory, _refreshEpic, _refreshGherkinTest, newEpic
                });
            }
            finally
            {
                EntityService.DeleteById <Epic>(WorkspaceContext, newEpic.Id);
            }
        }