public void AddCommentToPost()
        {
            Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>();

            uow.Setup(x => x.PostCommentRepository.GetByKey(1)).Returns(fakePostComments.Where(x => x.Id == 1).FirstOrDefault());
            uow.Setup(x => x.PostCommentRepository.GetPostComments(1)).Returns(fakePostComments);

            UserManager <AppUser> um  = new FakeUserManager();
            UserBlogService       ubs = new UserBlogService(uow.Object, um);
            UserBlogApiController UBC = new UserBlogApiController(ubs);

            UBC.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
                    {
                        new Claim(ClaimTypes.Name, "username")
                    }, "someAuthTypeName"))
                }
            };

            var result = UBC.AddCommentToPost(new UserBlogCommentModel()
            {
                BlogId = 1, ParentId = 1, Text = "text"
            }) as ObjectResult;

            result.Value.Should().NotBeNull();
            //uow.Verify(x => x.PostCommentRepository.Delete(It.IsAny<long>()));
        }
Ejemplo n.º 2
0
 public UserBlogController(UserBlogService userBlogService,
                           UserInfoService userInfoService, IMapper mapper)
 {
     this.userBlogService = userBlogService;
     this.userInfoService = userInfoService;
     this.mapper          = mapper;
 }
        public void DeleteCommentsToPost()
        {
            Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>();

            uow.Setup(x => x.PostCommentRepository.GetByKey((long)10)).Returns(new PostComment()
            {
                Id = 1
            }
                                                                               );
            uow.Setup(x => x.PostCommentRepository.GetPostComments((long)10)).Returns(new List <PostComment>()
            {
                new PostComment()
                {
                    Id = 10
                }
            }
                                                                                      );

            UserManager <AppUser> um  = new FakeUserManager();
            UserBlogService       ubs = new UserBlogService(uow.Object, um);
            UserBlogApiController UBC = new UserBlogApiController(ubs);

            var result = UBC.DeleteCommentsToPost(10) as EmptyResult;

            uow.Verify(x => x.PostCommentRepository.Delete(It.IsAny <long>()));
        }
Ejemplo n.º 4
0
 public FriendsController(FriendsService friendsService,
                          FriendRequestsService friendRequestsService, UserBlogService userBlogService)
 {
     this.friendsService        = friendsService;
     this.friendRequestsService = friendRequestsService;
     this.userBlogService       = userBlogService;
 }
 public PersonStatsApiController(IUnitOfWork _uow, UserManager <AppUser> userMgr, PersonService _ps, UserBlogService _ubs)
 {
     unitOfWork    = _uow;
     userManager   = userMgr;
     personService = _ps;
     postService   = _ubs;
 }
Ejemplo n.º 6
0
 public SearchController(UserInfoService userInfoService,
                         BlogService blogService, SectionsService sectionsService,
                         SearchService searchService, UserBlogService userBlogService)
 {
     this.userInfoService = userInfoService;
     this.blogService     = blogService;
     this.sectionsService = sectionsService;
     this.searchService   = searchService;
     this.userBlogService = userBlogService;
 }
Ejemplo n.º 7
0
        public PostController(PostService postService,
                              CommentService commentService, UserBlogService userBlogService,
                              UserInfoService userInfoService)
        {
            this.postService    = postService;
            this.commentService = commentService;

            /*this.userBlogService = userBlogService;
            *  this.userInfoService = userInfoService;*/
        }
        public void CreateBlogTest()
        {
            Mock <IUnitOfWork>    uow = new Mock <IUnitOfWork>();
            UserManager <AppUser> um  = new FakeUserManager();
            UserBlogService       ubs = new UserBlogService(uow.Object, um);
            UserBlogController    ubc = new UserBlogController(ubs);

            var result = ubc.CreateBlog() as ViewResult;

            result.Should().NotBeNull();
        }
        public void GetCommentsToPostTest()
        {
            Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>();

            uow.Setup(x => x.PostCommentRepository.GetPostComments(1)).Returns(fakePostComments);
            UserManager <AppUser> um  = new FakeUserManager();
            UserBlogService       ubs = new UserBlogService(uow.Object, um);
            UserBlogApiController UBC = new UserBlogApiController(ubs);

            var result = UBC.GetCommentsToPost(1) as ObjectResult;

            result.Value.Should().NotBeNull();
        }
        public void BlogViews()
        {
            Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>();

            uow.Setup(x => x.PostRepository.GetAll()).Returns(_fakePosts);
            UserManager <AppUser> um  = new FakeUserManager();
            UserBlogService       ubs = new UserBlogService(uow.Object, um);
            UserBlogController    ubc = new UserBlogController(ubs);

            var result = (ubc.BlogViews() as ViewResult)?.Model as IEnumerable <PostView>;

            Assert.NotNull(result);
            Assert.Equal(_fakePosts.Select(x => x.Id), result.Select(x => x.Id));
        }
        public void BlogView()
        {
            const long id = 1
            ;
            UserManager <AppUser> um  = new FakeUserManager();
            Mock <IUnitOfWork>    uow = new Mock <IUnitOfWork>();

            uow.Setup(x => x.PostRepository.GetByKey(id)).Returns(_fakePosts.FirstOrDefault(x => x.Id == id));
            UserBlogService    ubs = new UserBlogService(uow.Object, um);
            UserBlogController ubc = new UserBlogController(ubs);

            var result = (ubc.BlogView(id) as ViewResult)?.Model as PostView;

            Assert.NotNull(result);
            Assert.Equal(id, result.Id);
        }
Ejemplo n.º 12
0
        public MainPageDataViewComponent(SearchService searchService, FriendsService friendsService,
                                         BlockService blockService, ReactionService reactionService,
                                         UserBlogService userBlogService, SectionsService sectionsService,
                                         BlogService blogService, UserInfoService userInfoService)
        {
            this.searchService   = searchService;
            this.friendsService  = friendsService;
            this.blockService    = blockService;
            this.reactionService = reactionService;
            this.userBlogService = userBlogService;
            this.sectionsService = sectionsService;
            this.blogService     = blogService;
            this.userInfoService = userInfoService;

            this.randomizer = new Random();
        }
        public void UserBlogViewsTest()
        {
            string             userId = "1";
            Mock <IUnitOfWork> uow    = new Mock <IUnitOfWork>();

            uow.Setup(x => x.PostRepository.PostsByUserId(userId)).Returns(_fakePosts);
            UserManager <AppUser> um = new FakeUserManager();

            UserBlogService    ubs = new UserBlogService(uow.Object, um);
            UserBlogController ubc = new UserBlogController(ubs);

            var result = ubc.UserBlogViews("1") as ViewResult;

            Assert.NotNull(result);

            var model = result.Model as UserBlogView;

            Assert.NotNull(model);

            Assert.Equal(model.Posts.Count, _fakePosts.Count);
            Assert.Equal(model.AppUser, FakeUserManager.FakeUser);
        }
        public void AddBlogTest()
        {
            PostView pv = new PostView()
            {
                AuthorName       = "illya",
                Id               = 1,
                Title            = "title",
                PostDate         = DateTime.Today,
                Text             = "text",
                AuthorId         = "1",
                ImageId          = 1,
                ShortDescription = "shdesc"
            };
            Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>();

            uow.Setup(x => x.PostRepository.Add(It.IsAny <Post>()));
            uow.Setup(x => x.Save());
            UserManager <AppUser> um  = new FakeUserManager();
            UserBlogService       ubs = new UserBlogService(uow.Object, um);
            UserBlogApiController UBC = new UserBlogApiController(ubs);

            UBC.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
                    {
                        new Claim(ClaimTypes.Name, "username")
                    }, "someAuthTypeName"))
                }
            };

            var result = UBC.AddBlog(pv) as ObjectResult;

            uow.Verify(x => x.PostRepository.Add(It.IsAny <Post>()));
            uow.Verify(x => x.Save());
            //result.Value.Should().NotBeNull();
        }
Ejemplo n.º 15
0
 public UserBlogController(UserBlogService userBlogService)
 {
     _userBlogService = userBlogService;
 }
 public UserBlogApiController(UserBlogService blogService)
 {
     _blogService = blogService;
 }