public async Task GivenCommentaryController_WhenCreateCommentary_ThenShouldCallMethodCreate() { CommentaryController CommentaryController = new CommentaryController(_CommentaryService); ActionResult actionResult = await CommentaryController.CreateCommentary(new CommentaryDto() { Content = "ololo", UserId = "1", VideoId = new Guid() }); await _CommentaryService.Received(1).AddCommentary(Arg.Any <CommentaryDto>()); }
public async Task GivenCommentaryController_WhenGetCommentariesByVideoId_ThenShouldGetThisCommentaries() { CommentaryController CommentaryController = new CommentaryController(_CommentaryService); ActionResult actionResult = await CommentaryController.GetCommentariesByVideoId(new Guid()); var okResult = actionResult as ObjectResult; IEnumerable <CommentaryDto> Commentary = okResult.Value as IEnumerable <CommentaryDto>; Commentary.Should().BeEquivalentTo(Commentaries); }
public async Task GivenCommentaryController_WhenDeleteCommentary_Then_ShouldCallDeleteMethod() { ClaimsPrincipal user = Substitute.For <ClaimsPrincipal>(); user.Identity.Name.Returns("1"); CommentaryController CommentaryController = new CommentaryController(_CommentaryService); CommentaryController.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; ActionResult actionResult = await CommentaryController.DeleteCommentary(new Guid()); await _CommentaryService.Received(1).RemoveCommentary(Arg.Any <Guid>()); }