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); }
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); }
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); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }