コード例 #1
0
        public void MakeComment_OnSeedLaw_CommentMade()
        {
            var commmentText = "Test comment";
            var law          = Helpers.GetTestLaw();
            var user         = Helpers.CreateNewUser();

            JavnaRasprava.WEB.DomainModels.ApplicationDbContext context = null;
            try
            {
                context = JavnaRasprava.WEB.DomainModels.ApplicationDbContext.Create();

                new CommentsService().MakeComment(law.LawID, user.Id, commmentText);

                var response = new CommentsService().GetCommentsForLaw(law.LawID, user.Id, CommentOrder.Chronological);
                var comment  = response.Comments.Where(x => x.Comment.ApplicationUserID == user.Id && x.Comment.Text == commmentText).FirstOrDefault();

                Assert.IsNotNull(comment, "Comment not made");
                Assert.AreEqual(0, comment.VotesDown, "New Comment, no votes down yet");
                Assert.AreEqual(0, comment.VotesUp, "New Comment, no votes up yet");
                Assert.AreEqual(false, comment.UserVoted, "New Comment, no votes yet");
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }

                Helpers.DeleteUser(user);
            }
        }
コード例 #2
0
 public JavnaRasprava.WEB.DomainModels.ApplicationUser GetAnonymousUser(JavnaRasprava.WEB.DomainModels.ApplicationDbContext context)
 {
     return(context.Users.Single(x => x.UserName == "anonymous"));
 }