public void AddNewPost_modelStaitNotValid_posNotAddedReturnReqwest400() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); postCtrl.ModelState.AddModelError("SortVal", "test error"); var user = new ClaimsIdentity(); user.AddClaim(new Claim("Id", 1.ToString())); var principal = new ClaimsPrincipal(user); postCtrl.User = principal; // Act postCtrl.AddNewPost(new PostEditVm()); // Assert _postsBo.Received(0).AddNewPost(1, null, null, false); }
public void AddNewPost_postNotCreated_returnReqwest400() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); var user = new ClaimsIdentity(); user.AddClaim(new Claim("Id", 1.ToString())); var principal = new ClaimsPrincipal(user); postCtrl.User = principal; _postsBo.AddNewPost(1, null, null, false).Returns(false); // Act var result = postCtrl.AddNewPost(new PostEditVm()); // Assert Assert.IsNotNull(result); Assert.IsTrue(result is BadRequestErrorMessageResult); }
public void GetAllPosts_modelStaitNotValid_returnReqwest400() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); postCtrl.ModelState.AddModelError("SortVal", "test error"); // Act postCtrl.GetAllPosts(new PageSettingEditVm()); // Assert _postsBo.Received(0).GetPagePosts(null, PostOrderEnum.ByDate, 4, 1); }
public void GetUserPosts_modelStaitNotValid_returnReqwest400() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); postCtrl.ModelState.AddModelError("SortVal", "test error"); var user = new ClaimsIdentity(); user.AddClaim(new Claim("Id", 1.ToString())); var principal = new ClaimsPrincipal(user); postCtrl.User = principal; // Act postCtrl.GetUserPosts(new PageSettingEditVm()); // Assert _postsBo.Received(0).GetPageUserPosts(1,null, 4, 1); }
public void EditPost_postNotEdited_returnReqwest400() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); _postsBo.EditPost(0, null, null, false).Returns(false); // Act var result = postCtrl.EditPost(new PostEditVm()); // Assert Assert.IsNotNull(result); Assert.IsTrue(result is BadRequestErrorMessageResult); }
public void EditPost_postIsEdited_returnReqwest200() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); _postsBo.EditPost(0, null, null, false).Returns(true); // Act var result = postCtrl.EditPost(new PostEditVm()); // Assert Assert.IsNotNull(result); Assert.IsTrue(result is OkResult); }
public void EditPost_modelStaitNotValid_returnReqwest400() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); postCtrl.ModelState.AddModelError("SortVal", "test error"); // Act postCtrl.EditPost(new PostEditVm()); // Assert _postsBo.Received(0).EditPost(0, null, null, false); }
public void EditPostRate_postRatingIsEdited_returnReqwest200() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); var user = new ClaimsIdentity(); user.AddClaim(new Claim("Id", 1.ToString())); var principal = new ClaimsPrincipal(user); postCtrl.User = principal; _postsBo.RatingVote(1, 0, 0).Returns(true); // Act var result = postCtrl.EditPostRate(new PostRatingEditVm()); // Assert Assert.IsNotNull(result); Assert.IsTrue(result is OkResult); }
public void EditPostRate_modelStaitNotValid_returnReqwest400() { // Arrange var postCtrl = new PostsController(_postsBo, _userBo); //postCtrl.ModelState.AddModelError("SortVal", "test error"); var user = new ClaimsIdentity(); user.AddClaim(new Claim("Id", 1.ToString())); var principal = new ClaimsPrincipal(user); postCtrl.User = principal; // Act postCtrl.EditPostRate(new PostRatingEditVm()); // Assert _postsBo.Received(1).RatingVote(1, 0, 0); }