public void UpdateAsyncSuccessTest()
        {
            // Arrange
            IQbQuestionRepository repository = Substitute.For <IQbQuestionRepository>();
            IUnitOfWork           unitOfWork = Substitute.For <IUnitOfWork>();
            QbQuestion            question   = new QbQuestion();

            repository.FindByIdAsync(Arg.Any <int>()).Returns(question);
            repository.Update(Arg.Any <QbQuestion>()).Returns(true);
            unitOfWork.CompleteAsync().Returns(Task.CompletedTask);
            QbQuestionService service = new QbQuestionService(repository, unitOfWork);

            // Act
            Task <QbQuestionResponse> result = service.UpdateAsync(1, question);

            // Assert
            result.Result.Success.Should().Be(true);
        }
        public void UpdateAsyncFailureOnFindTest()
        {
            // Arrange
            IQbQuestionRepository repository = Substitute.For <IQbQuestionRepository>();
            IUnitOfWork           unitOfWork = Substitute.For <IUnitOfWork>();
            QbQuestion            question   = null;

            repository.FindByIdAsync(Arg.Any <int>()).Returns(question);
            QbQuestionService service = new QbQuestionService(repository, unitOfWork);

            // Act
            Task <QbQuestionResponse> result = service.UpdateAsync(1, question);

            // Assert
            string errorMessage = "Question not found.";

            result.Result.Success.Should().Be(false);
            result.Result.Message.Should().Be(errorMessage);
        }
        public void UpdateAsyncFailureOnUpdateTest()
        {
            // Arrange
            IQbQuestionRepository repository = Substitute.For <IQbQuestionRepository>();
            IUnitOfWork           unitOfWork = Substitute.For <IUnitOfWork>();
            QbQuestion            question   = new QbQuestion();

            repository.FindByIdAsync(Arg.Any <int>()).Returns(question);
            repository.Update(Arg.Any <QbQuestion>()).Throws(new Exception("Exception occurred on Update"));
            QbQuestionService service = new QbQuestionService(repository, unitOfWork);

            // Act
            Task <QbQuestionResponse> result = service.UpdateAsync(1, question);

            // Assert
            string errorMessage = "An error occurred when updating the question: Exception occurred on Update";

            result.Result.Success.Should().Be(false);
            result.Result.Message.Should().Be(errorMessage);
        }