public void DeleteAComment_GIVENIdParameter_WHENRemoving_THENItBecomesSuccessfully() { _commentRepository.GetComment(Arg.Any <int>(), Arg.Any <int>()).Returns(DomainTestBase.CreateAComment()); _commentService.DeleteAComment(1, 1); _commentRepository.Received(1).GetComment(Arg.Any <int>(), Arg.Any <int>()); _commentRepository.Received(1).Delete(Args.AnyEntity <Comment>()); }
public void Login_AreLoginInformationValid() { var request = new LoginRequest { MailAddress = "*****@*****.**", Password = "******" }; _userRepository.Query(Args.AnyEntity <User>()).Returns(default(IEnumerable <User>)); Assert.Throws <NotAuthenticationException>(() => _accountService.Login(request)); }
public void DeleteAPost_GIVENIdParameter_WHENRemoving_THENItBecomesSuccessfully() { _postRepository.GetPost(Arg.Any <int>(), Arg.Any <int>()).Returns(DomainTestBase.CreateAPost()); _postService.DeleteAPost(1); _cacheService.Remove(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); _postRepository.Received(1).GetPost(Arg.Any <int>(), Arg.Any <int>()); _postRepository.Received(1).Delete(Args.AnyEntity <Post>()); _cacheService.Received(1).Remove(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); }
public void GetAllComment_WHENGetting_THENItBecomesSuccessfully() { _commentRepository.Query(Args.AnyEntity <Comment>()).Returns(DomainTestBase.CreateAComment().ToList()); _mapperService.Map <IEnumerable <CommentResult> >(Arg.Any <List <Comment> >()) .Returns(new CommentResult { Id = 1, PostId = 1, FirstName = "test", LastName = "test", Message = "test" }.ToList()); var result = _commentService.GetAllComments(1); result.ShouldNotBeNull(); _commentRepository.Received(1).Query(Args.AnyEntity <Comment>()); }
public void Login_GIVENDeActiveUser_THENItShouldBeThrowsException() { var request = new LoginRequest { MailAddress = "*****@*****.**", Password = "******" }; var user = User.Create("test", "test", request.MailAddress, password: request.Password); user.IsActiveAuditing(false); var users = user.ToList(); _userRepository.Query(Args.AnyEntity <User>()).Returns(users); Assert.Throws <AccountIsNotActiveException>(() => _accountService.Login(request)); }
public void GetAllPost_WHENGettingDatabase_THENItBecomesSuccessfully() { _coreService.User.Id.Returns(1); _cacheService.GetList <PostResult>(Arg.Any <string>()).Returns((IEnumerable <PostResult>)null); _postRepository.Query(Args.AnyEntity <Post>()).Returns(DomainTestBase.CreateAPost().ToList()); _mapperService.Map <IEnumerable <PostResult> >(Arg.Any <List <Post> >()) .Returns(new PostResult { Id = 1, Title = "test" }.ToList()); var result = _postService.GetAllPost(); result.ShouldNotBeNull(); _postRepository.Received(1).Query(Args.AnyEntity <Post>()); _cacheService.Received(1).GetList <PostResult>(Arg.Any <string>()); }