public void History_Get_Test() { FakeDbEditor dbEditor = new FakeDbEditor(); SearchSystemsRequester service = new SearchSystemsRequester(); HomeController controller = new HomeController(dbEditor, service); var result = controller.History(); var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Home", redirectToActionResult.ControllerName); Assert.Equal("History", redirectToActionResult.ActionName); Assert.Null(controller.ViewBag.isDisplayEngine); }
public void History_Post_Test(string searchString) { FakeDbEditor dbEditor = new FakeDbEditor(); dbEditor.searchResults = new List <SearchResult>(); dbEditor.searchRequests = new List <SearchRequest>(); SearchSystemsRequester service = new SearchSystemsRequester(); HomeController controller = new HomeController(dbEditor, service); SearchResult searchResult = new SearchResult { SearchResultId = 1, Title = "Test title", Url = "test url", Description = "test description", IndexedTime = DateTime.Now }; List <SearchResult> req1 = new List <SearchResult>(); req1.Add(searchResult); SearchRequest searchRequest = new SearchRequest { SearchRequestId = 1, SearchString = searchString, SearchDate = DateTime.Now, SearchResults = req1 }; List <SearchRequest> req = (List <SearchRequest>)dbEditor.searchRequests; req.Add(searchRequest); dbEditor.searchRequests = req; List <SearchResult> res = (List <SearchResult>)dbEditor.searchResults; res.Add(searchResult); dbEditor.searchResults = res; var result = controller.History(searchString); Assert.IsType <ViewResult>(result); Assert.Null(controller.ViewBag.isDisplayEngine); Assert.Equal(typeof(SearchRequest), controller.ViewData.Model.GetType()); SearchRequest model = (SearchRequest)controller.ViewData.Model; Assert.True(model.SearchResults.Contains(searchResult)); }
public void GetCompliteUrl_Test(string expected, string searchQuery, string parameterName1, string parameterValue1, string parameterName2, string parameterValue2, string baseUrl) { List <RequestsParameter> parameters = new List <RequestsParameter>(); parameters.Add(new RequestsParameter { ParametrName = parameterName1, ParametrValue = parameterValue1, RequestsParameterId = 1 }); parameters.Add(new RequestsParameter { ParametrName = parameterName2, ParametrValue = parameterValue2, RequestsParameterId = 2 }); SearchSystemsRequester service = new SearchSystemsRequester(); string result = service.GetCompliteUrl(searchQuery, parameters, baseUrl); Assert.Equal(expected, result); }