Ejemplo n.º 1
0
        public void PostComment_NotFail_Test()
        {
            bool called = false;
            var expectedcomment = new Comment() { CommentId = 1 };

            ISessionRepository sessionRepository = new StubISessionRepository();
            ICommentRepository commentRepository = new StubICommentRepository()
            {
                AddComment = comment =>
                {
                    Assert.AreEqual(expectedcomment.CommentId, comment.CommentId);
                    called = true;
                    return expectedcomment.CommentId;
                }
            };

            using (ShimsContext.Create())
            {
                var target = new CommentsController(commentRepository, sessionRepository);
                var actual = target.Post(expectedcomment);

                Assert.IsTrue(called);
                Assert.AreEqual(expectedcomment.CommentId, actual);
            }
        }
Ejemplo n.º 2
0
        public void PostComment_ArgumentNullException_Test()
        {
            ICommentRepository commentRepository = new StubICommentRepository();
            IMaterialRepository materialRepository = new StubIMaterialRepository();
            IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository();
            ISessionRepository sessionRepository = new StubISessionRepository();

            var target = new CommentsController(commentRepository, sessionRepository);

            target.Post(null);
        }