コード例 #1
0
        public void ListByPostReturnsListOfComments()
        {
            FakeCommentService commentService = new FakeCommentService();
            FakePostService    postService    = new FakePostService();
            FakeAreaService    areaService    = new FakeAreaService();

            commentService.AllComments.Add(new Comment());
            commentService.AllComments.Add(new Comment());

            postService.AddedPosts.Add(new Post()
            {
                Slug = "test"
            });

            areaService.StoredAreas.Add("test", new Area());

            CommentController controller = new CommentController(postService, commentService, null, areaService)
            {
                ControllerContext = new System.Web.Mvc.ControllerContext()
                {
                    RouteData = new System.Web.Routing.RouteData()
                }
            };

            OxiteViewModelItems <Comment> result = controller.ListByPost(0, 50, new PostAddress("test", "test"), null);

            Assert.Equal(2, result.Items.Count());
            Assert.Same(commentService.AllComments[0], result.Items.ElementAt(0));
            Assert.Same(commentService.AllComments[1], result.Items.ElementAt(1));
            Assert.Same(postService.AddedPosts[0], result.Items.ElementAt(0).Parent);
            Assert.Same(postService.AddedPosts[0], result.Items.ElementAt(1).Parent);
        }
コード例 #2
0
        public void ListByAreaSetsAreaAsContainer()
        {
            FakeCommentService commentService = new FakeCommentService();
            FakePostService    postService    = new FakePostService();
            FakeAreaService    areaService    = new FakeAreaService();

            commentService.AllComments.Add(new Comment());
            commentService.AllComments.Add(new Comment());

            areaService.StoredAreas.Add("test", new Area());

            CommentController controller = new CommentController(postService, commentService, null, areaService)
            {
                ControllerContext = new System.Web.Mvc.ControllerContext()
                {
                    RouteData = new System.Web.Routing.RouteData()
                }
            };

            OxiteViewModelItems <Comment> result = controller.ListByArea(new Area()
            {
                Name = "test"
            });

            Assert.Same(areaService.StoredAreas["test"], result.Container);
        }
コード例 #3
0
        public void ListByPostSetsPostAsContainer()
        {
            FakeCommentService commentService = new FakeCommentService();
            FakePostService    postService    = new FakePostService();
            FakeAreaService    areaService    = new FakeAreaService();

            commentService.AllComments.Add(new Comment());
            commentService.AllComments.Add(new Comment());

            postService.AddedPosts.Add(new Post()
            {
                Slug = "test"
            });

            areaService.StoredAreas.Add("test", new Area());

            CommentController controller = new CommentController(postService, commentService, null, areaService)
            {
                ControllerContext = new System.Web.Mvc.ControllerContext()
                {
                    RouteData = new System.Web.Routing.RouteData()
                }
            };

            OxiteViewModelItems <Comment> result = controller.ListByPost(0, 50, new PostAddress("test", "test"), null);

            Assert.Same(postService.AddedPosts[0], result.Container);
        }
コード例 #4
0
        public void ListByTagReturnsListOfComments()
        {
            FakeCommentService commentService = new FakeCommentService();
            FakePostService    postService    = new FakePostService();
            FakeTagService     tagService     = new FakeTagService();

            commentService.AllComments.Add(new Comment());
            commentService.AllComments.Add(new Comment());

            tagService.StoredTags.Add("test", new Tag());

            CommentController controller = new CommentController(postService, commentService, tagService, null)
            {
                ControllerContext = new System.Web.Mvc.ControllerContext()
                {
                    RouteData = new System.Web.Routing.RouteData()
                }
            };

            OxiteViewModelItems <Comment> result = controller.ListByTag(new Tag()
            {
                Name = "test"
            });

            Assert.Equal(2, result.Items.Count());
            Assert.Same(commentService.AllComments[0], result.Items.ElementAt(0));
            Assert.Same(commentService.AllComments[1], result.Items.ElementAt(1));
        }
コード例 #5
0
        public void ListByTagSetsTagAsContainer()
        {
            FakeCommentService commentService = new FakeCommentService();
            FakePostService    postService    = new FakePostService();
            FakeTagService     tagService     = new FakeTagService();

            commentService.AllComments.Add(new Comment());
            commentService.AllComments.Add(new Comment());

            tagService.StoredTags.Add("test", new Tag());

            CommentController controller = new CommentController(postService, commentService, tagService, null)
            {
                ControllerContext = new System.Web.Mvc.ControllerContext()
                {
                    RouteData = new System.Web.Routing.RouteData()
                }
            };

            OxiteViewModelItems <Comment> result = controller.ListByTag(new Tag()
            {
                Name = "test"
            });

            Assert.Same(tagService.StoredTags["test"], result.Container);
        }
コード例 #6
0
        public virtual OxiteViewModelItems <Blog> FindQuery(BlogSearchCriteria searchCriteria)
        {
            IEnumerable <Blog>         foundBlogs = blogService.FindBlogs(searchCriteria);
            OxiteViewModelItems <Blog> model      = new OxiteViewModelItems <Blog>(foundBlogs);

            model.AddModelItem(searchCriteria);

            return(model);
        }
コード例 #7
0
        public OxiteViewModelItems <Role> FindQuery(RoleSearchCriteria searchCriteria)
        {
            IEnumerable <Role> foundRoles = roleService.FindRoles(searchCriteria);
            //TODO: (erikpo) Before the list is set into the model, filter it from the AuthorizationManager class (like make sure anonymous doesn't ever get sent down, etc)
            OxiteViewModelItems <Role> model = new OxiteViewModelItems <Role>(foundRoles);

            model.AddModelItem(searchCriteria);

            return(model);
        }
コード例 #8
0
        public OxiteViewModelItems <Blog> FindQuery(BlogSearchCriteria searchCriteria)
        {
            //TODO: (erikpo) Check permissions

            IEnumerable <Blog>         foundBlogs = blogService.FindBlogs(searchCriteria);
            OxiteViewModelItems <Blog> model      = new OxiteViewModelItems <Blog>(foundBlogs);

            model.AddModelItem(searchCriteria);

            return(model);
        }
コード例 #9
0
        public void ListReturnsNullListOnRequestForNonExistantPage()
        {
            FakePostService postService = new FakePostService();
            Guid            postID      = Guid.NewGuid();

            PostController controller = new PostController(null, postService, null, null, null);

            OxiteViewModelItems <Post> result = controller.List(2, 10, null);

            Assert.Null(result.Items);
        }
コード例 #10
0
        public void ListBySearchReturnsHomePageOnEmptySearch()
        {
            FakePostService postService = new FakePostService();

            PostController controller = new PostController(null, postService, null, null, null);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(new FakeHttpContext("~/"), new RouteData(), controller);

            OxiteViewModelItems <Post> result = controller.ListBySearch(null, 0, new SearchCriteria(), null);

            Assert.IsType <HomePageContainer>(result.Container);
        }
コード例 #11
0
        public OxiteViewModelItems <User> FindQuery(UserSearchCriteria searchCriteria)
        {
            //TODO: (erikpo) Check permissions

            IEnumerable <User> foundUsers = userService.FindUsers(searchCriteria);
            //TODO: (erikpo) Before the list is set into the model, filter it from the AuthorizationManager class (like make sure anonymous doesn't ever get sent down, etc)
            OxiteViewModelItems <User> model = new OxiteViewModelItems <User>(foundUsers);

            model.AddModelItem(searchCriteria);

            return(model);
        }
コード例 #12
0
        public void ListByArchiveSetsHomePageContainerOnModel()
        {
            FakePostService postService = new FakePostService();

            PostController controller = new PostController(null, postService, null, null, null);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(new FakeHttpContext("~/"), new RouteData(), controller);

            OxiteViewModelItems <Post> result = controller.ListByArchive(0, new ArchiveData());

            Assert.IsType <ArchiveContainer>(result.Container);
            Assert.Equal(new ArchiveData(), ((ArchiveContainer)result.Container).ArchiveData);
        }
コード例 #13
0
        public void ListBySearchSetsSearchContainerOnModel()
        {
            FakePostService postService = new FakePostService();

            PostController controller = new PostController(null, postService, null, null, null);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(new FakeHttpContext("~/"), new RouteData(), controller);

            OxiteViewModelItems <Post> result = controller.ListBySearch(null, 0, new SearchCriteria()
            {
                Term = "test"
            }, null);

            Assert.IsType <SearchPageContainer>(result.Container);
        }
コード例 #14
0
        public void ListReturnsPageNOnRequestForPageN()
        {
            FakePostService postService = new FakePostService();
            Guid            postID      = Guid.NewGuid();

            postService.PostPages.Add(3, new List <Post>(new[] { new Post()
                                                                 {
                                                                     ID = postID
                                                                 } }));

            PostController controller = new PostController(null, postService, null, null, null);

            OxiteViewModelItems <Post> result = controller.List(4, 10, null);

            Assert.Equal(1, result.Items.Count());
            Assert.Equal(postID, result.Items.ElementAt(0).ID);
        }
コード例 #15
0
        public void ListUsesIfModifiedSince()
        {
            FakePostService postService = new FakePostService();
            Guid            postID      = Guid.NewGuid();

            postService.PostPages.Add(0, new List <Post>(new[] { new Post()
                                                                 {
                                                                     ID = postID
                                                                 } }));

            PostController controller = new PostController(null, postService, null, null, null);

            DateTime sinceDate = DateTime.Now;

            OxiteViewModelItems <Post> result = controller.List(null, 10, sinceDate);

            Assert.Equal(sinceDate, postService.LastRequestedSinceDate);
        }
コード例 #16
0
        public void ListByAreaReturnsNullForInvalidArea()
        {
            FakePostService postService = new FakePostService();
            FakeAreaService areaService = new FakeAreaService();

            Area area = new Area()
            {
                Name = "test"
            };

            PostController controller = new PostController(areaService, postService, null, null, null);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(new FakeHttpContext("~/"), new RouteData(), controller);

            OxiteViewModelItems <Post> result = controller.ListByArea(null, 10, area, null);

            Assert.Null(result);
        }
コード例 #17
0
        public void ListByTagReturnsNullForInvalidArea()
        {
            FakePostService postService = new FakePostService();
            FakeTagService  tagService  = new FakeTagService();

            Tag tag = new Tag()
            {
                Name = "Test"
            };

            PostController controller = new PostController(null, postService, null, tagService, null);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(new FakeHttpContext("~/"), new RouteData(), controller);

            OxiteViewModelItems <Post> result = controller.ListByTag(null, 0, tag, null);

            Assert.Null(result);
        }
コード例 #18
0
        public void ListReturnsPageOneOnNullPageNumber()
        {
            FakePostService postService = new FakePostService();
            Guid            postID      = Guid.NewGuid();

            postService.PostPages.Add(0, new List <Post>(new[] { new Post()
                                                                 {
                                                                     ID = postID
                                                                 } }));

            PostController controller = new PostController(null, postService, null, null, null);

            OxiteViewModelItems <Post> result = controller.List(null, 10, null);

            Assert.Equal(1, result.Items.Count());
            Assert.Equal(postID, result.Items.ElementAt(0).ID);
            Assert.IsType <HomePageContainer>(result.Container);
            Assert.Equal(10, postService.LastRequestedPageSize);
        }
コード例 #19
0
        public void ListByTagSetsTagOnModel()
        {
            FakePostService postService = new FakePostService();
            FakeTagService  tagService  = new FakeTagService();

            Tag tag = new Tag()
            {
                Name = "Test"
            };

            tagService.StoredTags.Add("Test", tag);

            PostController controller = new PostController(null, postService, null, tagService, null);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(new FakeHttpContext("~/"), new RouteData(), controller);

            OxiteViewModelItems <Post> result = controller.ListByTag(null, 0, tag, null);

            Assert.Equal(tag.Name, result.Container.Name);
        }
コード例 #20
0
        public void ListSetsHomePageContainer()
        {
            FakeCommentService commentService = new FakeCommentService();
            FakePostService    postService    = new FakePostService();

            commentService.AllComments.Add(new Comment());
            commentService.AllComments.Add(new Comment());

            CommentController controller = new CommentController(postService, commentService, null, null)
            {
                ControllerContext = new System.Web.Mvc.ControllerContext()
                {
                    RouteData = new System.Web.Routing.RouteData()
                }
            };

            OxiteViewModelItems <Comment> result = controller.List();

            Assert.IsType <HomePageContainer>(result.Container);
        }
コード例 #21
0
        public void ListByAreaSetsAreaOnModel()
        {
            FakePostService postService = new FakePostService();
            FakeAreaService areaService = new FakeAreaService();

            Area area = new Area()
            {
                Name = "test"
            };

            areaService.StoredAreas.Add("test", area);

            PostController controller = new PostController(areaService, postService, null, null, null);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(new FakeHttpContext("~/"), new RouteData(), controller);

            OxiteViewModelItems <Post> result = controller.ListByArea(null, 10, area, null);

            Assert.Equal(area.Name, result.Container.Name);
        }
コード例 #22
0
        public OxiteViewModelItems <ScheduleItem> ListByEventAndTag(EventAddress eventAddress, TagAddress tagAddress, ScheduleItemFilterCriteria scheduleItemFilterCriteria)
        {
            Event evnt = eventService.GetEvent(eventAddress);

            if (evnt == null)
            {
                return(null);
            }

            Tag tag = tagService.GetTag(tagAddress);

            if (!string.IsNullOrEmpty(tagAddress.TagName) && tag == null)
            {
                return(null);
            }

            ScheduleItemTag scheduleItemTag = scheduleItemService.GetScheduleItemTag(tagService.GetTag(tagAddress));

            if (!string.IsNullOrEmpty(tagAddress.TagName) && scheduleItemTag == null)
            {
                return(null);
            }

            IPageOfItems <ScheduleItem> scheduleItems = scheduleItemService.GetScheduleItemsByTag(eventAddress, scheduleItemTag != null ? scheduleItemTag.ID : Guid.Empty, scheduleItemFilterCriteria);

            SetUserScheduleStatus();

            var model = new OxiteViewModelItems <ScheduleItem>(scheduleItems)
            {
                Container = evnt
            };

            model.AddModelItem(scheduleItemTag);

            return(model);
        }