Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }