예제 #1
0
        public void SlugReplacesTheSpecialCharactersWithHyphens()
        {
            var blogPost = new Post
            {
                Title = "This is a simple test title",
                Content = "Test Content",
                Author = "Minhajuddin",
                Timestamp = DateTime.Now
            };

            var expected = "This-is-a-simple-test-title";
            Assert.AreEqual(expected, blogPost.Slug);
        }
예제 #2
0
 public ActionResult Create(PostForm post)
 {
     var newPost = new Post { Title = post.Title, Content = post.Content };
     try {
         //TODO: Remove the hardcoded author name, Get it from the AppHelper
         newPost.Author = "Khaja Minhajuddin";
         newPost.Timestamp = DateTime.Now;
         _blogService.InsertPost(newPost);
     } catch {
         return View();
     }
     return RedirectToAction("Index");
 }
예제 #3
0
        public void GistIsEqualTo100CharactersWhenContentIsGreaterThan100Characters()
        {
            var blogPost = new Post
            {
                Title = "Test Title",
                Content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ligula. Duis non mauris ut enim ultricies sagittis. Proin varius, dolor quis malesuada auctor, diam elit pulvinar libero, nec laoreet nibh quam quis tellus. Praesent et eros. Nam sagittis tortor ut tortor. Aenean egestas, nisi ac luctus elementum, tortor turpis congue diam, vel pellentesque magna neque sed justo. Nullam congue enim eu quam. Aliquam euismod pulvinar mi. Duis libero turpis, rutrum convallis, posuere nec, tincidunt non, neque. Morbi a nisl. Proin eu leo. Vivamus dictum turpis vel magna. Nam vitae tortor vitae tortor consectetur consectetur. ",
                Author = "Minhajuddin",
                Timestamp = DateTime.Now
            };

            var result = blogPost.Gist.Length;
            Assert.AreApproximatelyEqual(100, result, 10);
        }
예제 #4
0
 public void InsertPostShouldBeAbleToCreateAPost()
 {
     var initialCount = blogService.GetAllPosts().Count();
     var post = new Post
     {
         Title = "Being inserted from the Test",
         Content = "And here is some content for you",
         Author = "Khaja",
         Timestamp = DateTime.Now.Date
     };
     blogService.InsertPost(post);
     var result = blogService.GetAllPosts().Count;
     Assert.AreEqual(initialCount + 1, result);
 }
예제 #5
0
        public void GistHasALengthEqualToLengthOfContentWhenContentLengthIsLessThan100Characters()
        {
            var blogPost = new Post
            {
                Title = "Test Title",
                Content = "Test Content",
                Author = "Minhajuddin",
                Timestamp = DateTime.Now
            };

            var expected = blogPost.Content.Length;
            var result = blogPost.Gist.Length;
            Assert.AreEqual(expected, result);
        }
예제 #6
0
 public void InsertPostInsertsAPostInTheDatabase()
 {
     var initialCount = _repository.GetPosts().Count();
     var post = new Post
     {
         Title = "Being inserted from the Test",
         Content = "And here is some content for you",
         Author = "Khaja",
         Timestamp = DateTime.Now.Date
     };
     _repository.Insert(post);
     _repository.Save();
     var result = _repository.GetPosts().Count();
     Assert.AreEqual(initialCount + 1, result);
 }
예제 #7
0
        public void HasATitleContentAuthorAndATimestamp()
        {
            DateTime blogPostTimestamp = DateTime.Now;
            var blogPost = new Post
            {
                Title = "Test Title",
                Content = "Test Content",
                Author = "Minhajuddin",
                Timestamp = blogPostTimestamp
            };

            Assert.AreEqual("Test Title", blogPost.Title);
            Assert.AreEqual("Test Content", blogPost.Content);
            Assert.AreEqual("Minhajuddin", blogPost.Author);
            Assert.AreEqual(blogPostTimestamp, blogPost.Timestamp);
        }
예제 #8
0
 public void Insert(Post newPost)
 {
     _db.Posts.InsertOnSubmit(newPost.ToEntityPost());
 }
예제 #9
0
 public void InsertPost(Post newPost)
 {
     _repository.Insert(newPost);
     _repository.Save();
 }
예제 #10
0
 public static string GetShortenedUrl(this UrlHelper helper, Post post)
 {
     var shortenedUrl = helper.Action("UrlShortener", new { id = post.ID });
     return shortenedUrl;
 }
예제 #11
0
 public static string GetPermaLink(this UrlHelper helper, Post post)
 {
     var permaLink = helper.Action("Post", new { id = post.ID, title = post.Slug });
     return permaLink;
 }
예제 #12
0
 public void CanCreateABlogPostWithAnEmptyConstructor()
 {
     var blogPost = new Post();
     Assert.IsNotNull(blogPost);
 }
예제 #13
0
 public void Insert(Post newPost)
 {
     posts.Add(newPost);
 }