コード例 #1
0
        public void AddComment()
        {
            NinjectComment.Resistration();
            var commentLogic = NinjectComment.Kernel.Get <ICommentLogic>();

            var newComment = new Comment()
            {
                Text     = "Good",
                BlogId   = 1,
                UserName = "******",
            };

            var newCommentId = commentLogic.AddComment(newComment);
            var commentDB    = new Comment();

            foreach (var comment in commentLogic.GetAllCommentsByBlogId(newComment.BlogId))
            {
                if (comment.CommentId == newCommentId)
                {
                    commentDB = comment;
                    break;
                }
            }
            Assert.IsNotNull(commentDB, "Last blog is null");
            Assert.AreEqual(newComment.Text, commentDB.Text, "Text Comment is not equal");
            Assert.AreEqual(newComment.BlogId, commentDB.BlogId, "BlogId Comment is not equal");
            Assert.AreEqual(newComment.UserName, commentDB.UserName, "UserName Comment is not equal");
        }
コード例 #2
0
        public void GetAllCommentsByBlogId()
        {
            NinjectComment.Resistration();
            var commentLogic = NinjectComment.Kernel.Get <ICommentLogic>();

            var newComment = new Comment()
            {
                Text     = "Good",
                BlogId   = 3,
                UserName = "******",
            };

            var newCommentId = commentLogic.AddComment(newComment);
            var commentDB    = commentLogic.GetAllCommentsByBlogId(newComment.BlogId).ToList();

            Assert.IsNotNull(commentDB);
            Assert.AreEqual(commentDB.Count, 1);
        }
コード例 #3
0
        public void GetAvgNote()
        {
            var logicBook = NinjectBook.Kernel.Get <IBookLogic>();

            NinjectComment.Registration();
            var logicComment = NinjectComment.Kernel.Get <ICommentLogic>();

            var newBook = new Book()
            {
                Title       = "Test name",
                Author      = "Test author",
                Genre       = "Roman",
                Description = "Test description",
                Compiler    = "Avatar",
            };
            var idBook      = logicBook.AddBook(newBook);
            var newComment1 = new Comment()
            {
                Book = idBook,
                User = "******",
                Note = (float)7,
                Text = "Bla-bla-bla-bla",
            };
            var newComment2 = new Comment()
            {
                Book = idBook,
                User = "******",
                Note = (float)6,
                Text = "Blu-blu-blu-blu",
            };

            logicComment.AddComment(newComment1);
            logicComment.AddComment(newComment2);
            int note = logicBook.GetAvgNote(idBook);

            Assert.AreEqual(note, 7, "Avg note is not valid");
        }