public void Log_Search_Can_Persist() { // Add a new search _logViewer.AddSavedSearch("Unit Test Example", "Has(UnitTest)"); IReadOnlyList <SavedLogSearch> searches = _logViewer.GetSavedSearches(); var savedSearch = new SavedLogSearch { Name = "Unit Test Example", Query = "Has(UnitTest)" }; // Check if we can find the newly added item from the results we get back IEnumerable <SavedLogSearch> findItem = searches.Where(x => x.Name == "Unit Test Example" && x.Query == "Has(UnitTest)"); Assert.IsNotNull(findItem, "We should have found the saved search, but get no results"); Assert.AreEqual(1, findItem.Count(), "Our list of searches should only contain one result"); // TODO: Need someone to help me find out why these don't work // CollectionAssert.Contains(searches, savedSearch, "Can not find the new search that was saved"); // Assert.That(searches, Contains.Item(savedSearch)); // Remove the search from above & ensure it no longer exists _logViewer.DeleteSavedSearch("Unit Test Example", "Has(UnitTest)"); searches = _logViewer.GetSavedSearches(); findItem = searches.Where(x => x.Name == "Unit Test Example" && x.Query == "Has(UnitTest)"); Assert.IsEmpty(findItem, "The search item should no longer exist"); }
public IEnumerable <SavedLogSearch> DeleteSavedSearch(SavedLogSearch item) { return(_logViewer.DeleteSavedSearch(item.Name, item.Query)); }
public IEnumerable <SavedLogSearch>?DeleteSavedSearch(SavedLogSearch item) => _logViewer.DeleteSavedSearch(item.Name, item.Query);