Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public void TaskService_AddComment_ThrowsDatabaseUpdateException()
        {
            var taskService = new TaskService(null);

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

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