Example #1
0
        public async Task TaskService_AddComment_CommentAddedInDatabase()
        {
            var comment = new Comment
            {
                Text   = "My new comment",
                UserId = null
            };
            var taskService = new TaskService(_dbContext);

            await taskService.AddCommentAsync(_task.Id, comment);

            _dbContext.Tasks.FirstOrDefault(x => x.Id == _task.Id).Comments.Should().Contain(comment);
        }
Example #2
0
        public void TaskService_AddComment_ThrowsDatabaseUpdateException()
        {
            var taskService = new TaskService(null);

            Assert.ThrowsAsync <DatabaseUpdateException>(() => taskService.AddCommentAsync("bob", new Comment()));
        }
Example #3
0
        public void TaskService_AddComment_ThrowsNoDatabaseObjectFoundException()
        {
            var taskService = new TaskService(_dbContext);

            Assert.ThrowsAsync <NoDatabaseObjectFoundException>(() => taskService.AddCommentAsync("bob", new Comment()));
        }