public void GetBookmark_WithTitleSuccess_ReturnBookmark()
        {
            //create mock objects

            var bookmarkRepo = new Mock <IBookmarkRepository>();

            var controller = new BookmarksController(bookmarkRepo.Object);

            Bookmark sample;

            //get a bookmark successfully and test that Titles are the same

            bookmarkRepo.Setup(x => x.GetBookmark("test")).Returns(sample = new Bookmark {
                Title = "test"
            });

            var result = controller.GetBookmark("test");

            bool id     = sample.BookmarkId == result.BookmarkId;
            bool author = sample.AuthorId == result.AuthorId;
            bool date   = sample.Date == result.Date;
            bool link   = sample.Link == result.Link;
            bool title  = sample.Title == result.Title;
            bool users  = sample.Users.Equals(result.Users);

            Assert.IsTrue(id && author && date && link && title && users);
        }
        public void GetBookmark_WithIdSuccess_ReturnBookmark()
        {
            //create mock objects

            var bookmarkRepo = new Mock <IBookmarkRepository>();
            var controller   = new BookmarksController(bookmarkRepo.Object);

            //get a bookmark

            Bookmark sample;

            bookmarkRepo.Setup(x => x.GetBookmark(1)).Returns(sample = new Bookmark {
                BookmarkId = 1
            });

            var result = controller.GetBookmark(1);

            //check that are equal

            bool id     = sample.BookmarkId == result.BookmarkId;
            bool author = sample.AuthorId == result.AuthorId;
            bool date   = sample.Date == result.Date;
            bool link   = sample.Link == result.Link;
            bool title  = sample.Title == result.Title;
            bool users  = sample.Users.Equals(result.Users);

            Assert.IsTrue(id && author && date && link && title && users);
        }
        public void GetBookmark_NoTitle_ThrowException()
        {
            //create mock objects

            var bookmarkRepo = new Mock <IBookmarkRepository>();

            var controller = new BookmarksController(bookmarkRepo.Object);

            //call get bookmark that will throw exception

            bookmarkRepo.Setup(x => x.GetBookmark("test")).Throws(new HttpResponseException(HttpStatusCode.Conflict));

            controller.GetBookmark("test");

            Assert.Fail();
        }