Beispiel #1
0
        public void BasicSearch_NonDefault_Parameters()
        {
            //arrange
            var mockLogic = new Mock <IProjectLogic>();
            var obj       = new SearchResult <ProjectObj>
            {
                HasMore     = false,
                HasPrevious = true,
                Results     = new List <ProjectObj>()
                {
                    new ProjectObj()
                    {
                        Id = 2
                    }
                }
            };

            mockLogic.Setup(l => l.Search("query", 5, 10)).Returns(obj);
            var controller = new ProjectController(mockLogic.Object);

            //act
            var actual = controller.BasicSearch("query", 5, 10) as ViewResult;

            //assert
            Assert.IsNotNull(actual);
            var model = actual.Model as BasicSearchModel;

            Assert.IsNotNull(model);
            Assert.AreEqual(5, model.CurrentPage);
            Assert.AreEqual(false, model.HasMoreResults);
            Assert.AreEqual(true, model.HasPriorResults);
            Assert.AreEqual("Project", model.ModelName);
            Assert.AreEqual(10, model.PageSize);
            Assert.AreEqual("query", model.Query);
            Assert.AreEqual(1, model.Results.Count);
            Assert.AreEqual(2, model.Results[0].Id);
        }