Beispiel #1
0
 /// <summary>
 /// modify the title and body of the post
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="post"></param>
 /// <param name="title"></param>
 /// <param name="body"></param>
 public static void ModiftyPost(Post post, string title, string body, Category category, Subcategory subcategory, Locale local, Area area)
 {
     using (var db = new ApplicationDbContext())
     {
         Biz1.Modify(post, title, body, category, subcategory, local, area);
         db.SaveChanges();
     }
 }
Beispiel #2
0
        public void DetermineExpiredTest()
        {
            //creating objects necessary to test Create Post Test Method
            //fields that need to be fed
            Post nonExpiredPost = CreateExpiredPost(false);
            Post expiredPost    = CreateExpiredPost(true);

            Assert.IsNotNull(Biz1.DetermineExpired(expiredPost));
            Assert.IsTrue(Biz1.DetermineExpired(expiredPost));
            Assert.IsNotNull(Biz1.DetermineExpired(nonExpiredPost));
            Assert.IsFalse(Biz1.DetermineExpired(nonExpiredPost));
        }
Beispiel #3
0
        public void ModifyTest()
        {
            Post p = CreateRegularPost();

            Assert.IsNotNull(p);
            Assert.AreEqual(p.Title, "Bubble Tea");
            Biz1.Modify(p, "Naixue", p.Body, p.PostCategory, p.PostSubcategory, p.PostLocale, p.PostArea);
            Assert.AreEqual(p.Title, "Naixue");
            Assert.AreEqual(p.Body, "Bubble Tea in longhua Jiufang");
            Biz1.Modify(p, p.Title, "Red Mountain and Xili", p.PostCategory, p.PostSubcategory, p.PostLocale, p.PostArea);
            Assert.AreEqual(p.Body, "Red Mountain and Xili");
        }
Beispiel #4
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);
        }
Beispiel #5
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;
        }