Example #1
0
        public void ShouldNotNull()
        {
            var resource = new StudentResourceParameters();

            resource.PageSize = 20;

            var controller = new StudentsController(_unitOfWork, _urlHelper)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext
                }
            };

            var sut = controller.GetAllPost(resource);

            var result = Assert.IsType <OkObjectResult>(sut);

            Assert.IsType <List <StudentDTO> >(result.Value);

            Assert.NotNull(sut);
        }
Example #2
0
        public void ShouldReturnCorrectSize()
        {
            var resource = new StudentResourceParameters();

            resource.PageSize   = 15;
            resource.PageNumber = 2;

            var controller = new StudentsController(_unitOfWork, _urlHelper)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext
                }
            };
            var sut = controller.GetAllPost(resource);

            var okResult     = Assert.IsType <OkObjectResult>(sut);
            var returnObject = Assert.IsType <List <StudentDTO> >(okResult.Value);

            Assert.Equal(StudentResourceParameters.maxPageSize, returnObject.Count);
            Assert.True(!returnObject.Contains(Mapper.Map <StudentDTO>(_randomStudent[1])));
            AssertObjects.PropertyValuesAreEquals(returnObject[0], Mapper.Map <StudentDTO>(_randomStudent[10]));
        }
Example #3
0
        public void ShouldReturnCorrectItem()
        {
            var resource = new StudentResourceParameters();

            resource.PageSize   = 15;
            resource.PageNumber = 1;
            resource.Name       = "N";


            var controller = new StudentsController(_unitOfWork, _urlHelper)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext
                }
            };
            var sut = controller.GetAllPost(resource);

            var okResult     = Assert.IsType <OkObjectResult>(sut);
            var returnObject = Assert.IsType <List <StudentDTO> >(okResult.Value);

            Assert.True(returnObject.All(x => x.Name.ToUpperInvariant().Contains(resource.Name.ToUpperInvariant())));
        }