public void Put_WithValidValues_CallsUpdateAndCommit()
        {
            BookmarkDto dto = new BookmarkDto(bookmarksTest[0]);

            uowMock.Setup(u => u.Bookmarks).Returns(bookmarkRepositoryMock.Object);

            HttpResponseMessage actual = sut.Put(1, dto);

            Assert.AreEqual(HttpStatusCode.OK, actual.StatusCode);

            bookmarkRepositoryMock.Verify(b => b.Update(It.IsAny<Bookmark>()), Times.Once());
            uowMock.Verify(u => u.Commit(), Times.Once());
        }
        public void Post_WithValidValues_CallsAddAndCommit()
        {
            BookmarkDto dto = new BookmarkDto(bookmarksTest[0]);
            uowMock.Setup(u => u.Progresses.GetById(1)).Returns(progressTest);
            uowMock.Setup(u => u.Bookmarks).Returns(bookmarkRepositoryMock.Object);

            HttpResponseMessage actual = sut.Post(dto);

            Assert.AreEqual(HttpStatusCode.Created, actual.StatusCode);

            bookmarkRepositoryMock.Verify(b => b.Add(It.IsAny<Bookmark>()), Times.Once());
            uowMock.Verify(u => u.Commit(), Times.Once());

            Assert.AreEqual("http://localhost/api/bookmark/1", actual.Headers.Location.ToString());
        }
        public void Put_WithInvalidProgressDto_ThrowBadRequest()
        {
            HttpResponseException exception = null;
            try
            {
                BookmarkDto dto = new BookmarkDto(bookmarksTest[0]);
                dto.UserName = null;

                sut.ModelState.AddModelError("UserName", "Can't find the value");
                sut.Put(1, dto);
            }
            catch (HttpResponseException ex)
            {
                exception = ex;
            }
            Assert.IsNotNull(exception);
            Assert.AreEqual(HttpStatusCode.BadRequest, exception.Response.StatusCode);
        }
        public void Post_ToAFinishedProgress_ThrowsNotAllowed()
        {
            BookmarkDto dto = new BookmarkDto(bookmarksTest[0]);
            progressTest.IsFinished = true;

            uowMock.Setup(u => u.Progresses.GetById(1)).Returns(progressTest);

            HttpResponseException exception = null;
            try
            {
                HttpResponseMessage actual = sut.Post(dto);
            }
            catch (HttpResponseException ex)
            {
                exception = ex;
            }
            Assert.IsNotNull(exception);
            Assert.AreEqual(HttpStatusCode.MethodNotAllowed, exception.Response.StatusCode);
        }