public void Count() { // Arrange CommentRepository commentRepository = new CommentRepository(dbContext); int expectedCommentsInDb = Resources.Classes.DbFiller.Instance.CommentAmount; // Act int actualCommentsInDb = commentRepository.Count(); // Assert Assert.AreEqual(expectedCommentsInDb, actualCommentsInDb); }
public void CountIfMonthIs7() { // Arrange CommentRepository commentRepository = new CommentRepository(dbContext); int monthNumber = 7; int expectedCommentsOn7Month = Resources.Classes.DbFiller.Instance.GetCommentByMonth(monthNumber); // Act int actualCommentsOn7Month = commentRepository.Count(comment => comment.Date.Month == monthNumber); // Assert Assert.AreEqual(expectedCommentsOn7Month, actualCommentsOn7Month); }
public JsonResult GetAllComments(int dataid) { var userprofile = Session["UserProfile"] as UserProfileVM; var userid = 0; if (userprofile != null) { userid = userprofile.User.ID; } var data = new CommentRepository().GetAllComments(userid, dataid); var total = data.Count(); return(Json(new { data = data, total = total }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 得到统计信息 /// </summary> /// <returns></returns> public IDictionary <string, string> GetRefstatInfo() { double totalDayCount = (DateTime.Now - Convert.ToDateTime("2009-01-01")).Days; int todayVisitorCount = _logRepository.SiteVisitCountOnToday(); int totalVisitorCount = _logRepository.SiteVisitCount(); int PostCount = _postRepository.Count(); int commentCount = _commentRepository.Count(); int boardCount = _boardRepository.Count(); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("今日访问量", todayVisitorCount.ToString()); data.Add("总访问人数", totalVisitorCount.ToString()); data.Add("文章总数", PostCount.ToString()); data.Add("评论总数", commentCount.ToString()); data.Add("留言总数", boardCount.ToString()); data.Add("平均日访问量", (totalVisitorCount / totalDayCount).ToString("#0.00")); data.Add("平均日新增文章数", (PostCount / totalDayCount).ToString("#0.00")); data.Add("平均日新增评论数", (commentCount / totalDayCount).ToString("#0.00")); data.Add("平均日新增留言数", (boardCount / totalDayCount).ToString("#0.00")); return(data); }
public Int32 GetCommentsCount(Guid postId) { return(_commentRepository.Count(p => p.PostId == postId && !p.IsDeleted)); }
public int Count() { return(CommentRepository.Count()); }