public void AddTest() { var postID = Guid.Empty.ToString(); var post = new Post(); post.ID = postID; var postCategoryList = new PagedList <PostCategory>(new PostCategory[] { }, 1, 10, 1); AddRole("Author"); _postRepositoryMock.Expect(r => r.Create()).Return(post); _postCategoryRepositoryMock.Expect(r => r.List(1, int.MaxValue)).Return(postCategoryList); var result = TestedController.Add(); VerifyViewResult(result, "Edit", typeof(EditPostData)); var resultModel = (EditPostData)((ViewResult)result).ViewData.Model; Assert.That(resultModel.EditMode, Is.EqualTo(EditMode.Add)); Assert.That(resultModel.Post, Is.EqualTo(post)); Assert.That(resultModel.PostCategories, Is.SameAs(postCategoryList.Items)); }
public void AddTest( [Values(null, "PostID")] string postID) { var postCommentID = Guid.Empty.ToString(); var postComment = new PostComment(); postComment.ID = postCommentID; _postCommentRepositoryMock.Expect(r => r.Create()).Return(postComment); Post post; if (postID != null) { post = new Post(); post.ID = postID; _postRepositoryMock.Expect(r => r.Get(postID)).Return(post); } else { post = null; } var result = TestedController.Add(postID); VerifyViewResult(result, "Edit", typeof(EditPostCommentData)); var resultModel = (EditPostCommentData)((ViewResult)result).ViewData.Model; Assert.That(resultModel.EditMode, Is.EqualTo(EditMode.Add)); Assert.That(resultModel.PostComment.Post, Is.EqualTo(post)); }
public void ShouldReturnBaseServiceResultSuccess() { AddCommentModel model = null; BaseServiceResult <Guid> result = TestedController.Add(model); Assert.NotNull(result); Assert.True(result.IsSuccess); Assert.Empty(result.ErrorMessage); }
public void AddTest() { var positionReport = new PositionReport(); AddRole("Author"); _positionReportRepositoryMock.Expect(r => r.Create()).Return(positionReport); var result = TestedController.Add(); VerifyViewResult(result, "Edit", typeof(EditPositionReportData)); var resultModel = (EditPositionReportData)((ViewResult)result).ViewData.Model; Assert.That(resultModel.EditMode, Is.EqualTo(EditMode.Add)); Assert.That(resultModel.PositionReport, Is.EqualTo(positionReport)); }
public void AddWithPostNotFoundTest() { var postID = "TestPostID"; _postRepositoryMock.Expect(r => r.Get(postID)).Return(null); try { var result = TestedController.Add(postID); Assert.Fail("404 not raised."); } catch (HttpException ex) { Assert.That(ex.GetHttpCode(), Is.EqualTo(404)); } }
public void AddTest() { var postCategoryID = Guid.Empty.ToString(); var postCategory = new PostCategory(); postCategory.ID = postCategoryID; AddRole("Author"); _postCategoryRepositoryMock.Expect(r => r.Create()).Return(postCategory); var result = TestedController.Add(); VerifyViewResult(result, "Edit", typeof(EditPostCategoryData)); var resultModel = (EditPostCategoryData)((ViewResult)result).ViewData.Model; Assert.That(resultModel.EditMode, Is.EqualTo(EditMode.Add)); Assert.That(resultModel.PostCategory, Is.EqualTo(postCategory)); }
public void ShouldReturnBaseServiceResultError() { AssertBaseServiceResultError(() => TestedController.Add(It.IsAny <AddCommentModel>())); }