예제 #1
0
        public void Search_Partial_Full_Last_Page()
        {
            //arrange
            var mockRepository = new Mock <IInnerTrackRepository>();
            var expected       = new List <ProjectObj>()
            {
                new ProjectObj()
                {
                    Id = 10
                }
            };

            mockRepository.Setup(m => m.GetProjects(It.Is <ProjectFilter>(f => f.MaxResults == 3 &&
                                                                          f.StartIndex == 4 &&
                                                                          f.QueryNames.Count == 2 &&
                                                                          f.QueryNames.Contains("dog") &&
                                                                          f.QueryNames.Contains("cat") &&
                                                                          f.QueryDescriptions.Count == 2 &&
                                                                          f.QueryDescriptions.Contains("dog") &&
                                                                          f.QueryDescriptions.Contains("cat")))).Returns(expected);
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Search("dog cat", 2, 2);

            //assert
            Assert.AreEqual(1, actual.Results.Count);
            Assert.AreEqual(expected[0].Id, actual.Results[0].Id);
            Assert.IsTrue(actual.HasPrevious);
            Assert.IsFalse(actual.HasMore);
        }
예제 #2
0
        public ActionResult BasicSearch(string query, int?currentPage = null, int?pageSize = null)
        {
            currentPage = currentPage ?? 0;
            pageSize    = pageSize ?? 20;

            var searchResult = ProjectLogic.Search(query, currentPage.Value, pageSize.Value);
            var results      = ModelConverter.ConvertToSearch(searchResult.Results);

            var model = new BasicSearchModel
            {
                CurrentPage     = currentPage.Value,
                PageSize        = pageSize.Value,
                Query           = query,
                ModelName       = "Project",
                HasMoreResults  = searchResult.HasMore,
                HasPriorResults = searchResult.HasPrevious,
                Results         = results
            };

            return(View("BasicSearch", model));
        }
예제 #3
0
        public void Search_No_Results()
        {
            //arrange
            var mockRepository = new Mock <IInnerTrackRepository>();

            mockRepository.Setup(m => m.GetProjects(It.Is <ProjectFilter>(f => f.MaxResults == 3 &&
                                                                          f.StartIndex == 0 &&
                                                                          f.QueryNames.Count == 2 &&
                                                                          f.QueryNames.Contains("dog") &&
                                                                          f.QueryNames.Contains("cat") &&
                                                                          f.QueryDescriptions.Count == 2 &&
                                                                          f.QueryDescriptions.Contains("dog") &&
                                                                          f.QueryDescriptions.Contains("cat")))).Returns(new List <ProjectObj>());
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Search("dog cat", 0, 2);

            //assert
            Assert.AreEqual(0, actual.Results.Count);
            Assert.IsFalse(actual.HasPrevious);
            Assert.IsFalse(actual.HasMore);
        }