Exemple #1
0
        /// <summary>
        /// List<Post> of expired and unexpired posts created by the User
        ///Description: Lists all posts of a given user, regardless whether the posts are expired or not
        /// </summary>
        /// <returns>List<Post> post</returns>
        public static List <Post> ListPosts(ApplicationUser user)
        {
            List <Post> posts = new List <Post>();

            using (var db = new ApplicationDbContext())
            {
                var postsObj = from post in db.Posts
                               where (user.Id == post.Owner.Id)
                               select post;
                posts = postsObj.ToList();
                posts = Biz1.ProcessExpiredPost(posts);
                db.SaveChanges();
            }

            return(posts);
        }
Exemple #2
0
        public void ProcessExpiredPostTest()
        {
            //create post objects
            Post p1 = CreateExpiredPost(false);
            Post p2 = CreateExpiredPost(true);
            //create list
            List <Post> posts = new List <Post>();

            posts.Add(p1);
            posts.Add(p2);
            //make sure the list is not null
            Assert.IsNotNull(posts);
            posts = Biz1.ProcessExpiredPost(posts);
            //make sure after the function, the list is not null
            Assert.IsNotNull(posts);
            //test result
            Assert.IsTrue(posts[0].Viewable);
            Assert.IsFalse(posts[1].Viewable);

            //end of creating a new post;
        }