public void CallIndexAction_WithoutParams_EnsureTheModelIsProperlyCreated() { // Arrange using (var controller = new SearchResultsController()) { // Act var view = controller.Index(null); // Asserts Assert.IsNull(view, "No results are displayed."); } }
public void SearchResultsWidget_DefaultLanguage_Limit_OldestOrder() { Guid searchIndex1Id = Guid.Empty; try { searchIndex1Id = SitefinityOperations.ServerOperations.Search().CreateSearchIndex(SearchResultsWidgetTests.SearchIndexName, new[] { SitefinityOperations.SearchContentType.Pages, SitefinityOperations.SearchContentType.News }); SitefinityOperations.ServerOperations.Search().Reindex(searchIndex1Id); int index = 1; string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "NewsPage" + index; string pageTitlePrefix = testName + "NewsPage" + index; string urlNamePrefix = testName + "news-page" + index; string orderBy = "Oldest"; var searchResultsController = new SearchResultsController(); searchResultsController.Model.DisplayMode = Telerik.Sitefinity.Frontend.Search.Mvc.Models.ListDisplayMode.Limit; searchResultsController.Model.ItemsPerPage = 2; int expectedResultsCount = 2; var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(NewsController).FullName; var newsController = new NewsController(); mvcProxy.Settings = new ControllerSettings(newsController); this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index); searchResultsController.Index(null, SearchResultsWidgetTests.NewsTitle, SearchResultsWidgetTests.SearchIndexName, null, null, orderBy); //// ignored because total count of returned results is 5 instead of 2 Assert.AreEqual(expectedResultsCount, searchResultsController.Model.Results.TotalCount); Assert.AreEqual(SearchResultsWidgetTests.NewsTitle + "1", searchResultsController.Model.Results.Data[0].GetValue("Title")); Assert.AreEqual(SearchResultsWidgetTests.NewsTitle + "2", searchResultsController.Model.Results.Data[1].GetValue("Title")); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Search().DeleteAllIndexes(); } }
public void SearchResultsWidget_DefaultLanguage_NoResultsFound() { Guid searchIndex1Id = Guid.Empty; try { searchIndex1Id = SitefinityOperations.ServerOperations.Search().CreateSearchIndex(SearchResultsWidgetTests.SearchIndexName, new[] { SitefinityOperations.SearchContentType.Pages, SitefinityOperations.SearchContentType.News }); SitefinityOperations.ServerOperations.Search().Reindex(searchIndex1Id); int index = 1; string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "NewsPage" + index; string pageTitlePrefix = testName + "NewsPage" + index; string urlNamePrefix = testName + "news-page" + index; string orderBy = "Oldest"; string searchString = "TestEvents"; int expectedCount = 0; var searchResultsController = new SearchResultsController(); var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(NewsController).FullName; var newsController = new NewsController(); mvcProxy.Settings = new ControllerSettings(newsController); this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index); searchResultsController.Index(null, searchString, SearchResultsWidgetTests.SearchIndexName, null, null, orderBy); Assert.AreEqual(expectedCount, searchResultsController.Model.Results.TotalCount); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Search().DeleteAllIndexes(); } }
public void SearchResultsWidget_NonDefaultLanguage_ResultsFound_OldestOrder() { Guid searchIndex1Id = Guid.Empty; try { searchIndex1Id = SitefinityOperations.ServerOperations.Search().CreateSearchIndex(SearchResultsWidgetTests.SearchIndexName, new[] { SitefinityOperations.SearchContentType.Pages, SitefinityOperations.SearchContentType.News }); SitefinityOperations.ServerOperations.Search().Reindex(searchIndex1Id); int index = 1; string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "NewsPage" + index; string pageTitlePrefix = testName + "NewsPage" + index; string urlNamePrefix = testName + "news-page" + index; var frontEndLanguages = AppSettings.CurrentSettings.DefinedFrontendLanguages; var language = frontEndLanguages[2].Name; string orderBy = "Oldest"; var searchResultsController = new SearchResultsController(); var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(NewsController).FullName; var newsController = new NewsController(); mvcProxy.Settings = new ControllerSettings(newsController); this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index); searchResultsController.Index(null, SearchResultsWidgetTests.NewsTitle, SearchResultsWidgetTests.SearchIndexName, null, language, orderBy); Assert.AreEqual(1, searchResultsController.Model.Results.TotalCount); Assert.AreEqual(SearchResultsWidgetTests.NewsTitle + "20", searchResultsController.Model.Results.Data[0].GetValue("Title")); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Search().DeleteAllIndexes(); } }
public void SearchResultsWidget_DefaultLanguage_NoLimit_NewestOrder() { Guid searchIndex1Id = Guid.Empty; try { searchIndex1Id = SitefinityOperations.ServerOperations.Search().CreateSearchIndex(SearchResultsWidgetTests.SearchIndexName, new[] { SitefinityOperations.SearchContentType.News }); SitefinityOperations.ServerOperations.Search().Reindex(searchIndex1Id); int index = 1; string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "NewsPage" + index; string pageTitlePrefix = testName + "NewsPage" + index; string urlNamePrefix = testName + "news-page" + index; string orderBy = "Newest"; var searchResultsController = new SearchResultsController(); searchResultsController.Model.DisplayMode = Telerik.Sitefinity.Frontend.Search.Mvc.Models.ListDisplayMode.All; searchResultsController.Model.ItemsPerPage = 2; var mvcProxy = new MvcControllerProxy(); mvcProxy.ControllerName = typeof(NewsController).FullName; var newsController = new NewsController(); mvcProxy.Settings = new ControllerSettings(newsController); this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index); searchResultsController.Index(null, SearchResultsWidgetTests.NewsTitle, SearchResultsWidgetTests.SearchIndexName, null, this.frontEndLanguages[0].Name, orderBy); Assert.AreEqual(SearchResultsWidgetTests.NewsCount, searchResultsController.Model.Results.TotalCount); for (int i = 0; i < SearchResultsWidgetTests.NewsCount; i++) { Assert.AreEqual(SearchResultsWidgetTests.NewsTitle + (SearchResultsWidgetTests.NewsCount - i), searchResultsController.Model.Results.Data[i].GetValue("Title")); } } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Search().DeleteAllIndexes(); } }