public async Task Handler_ValidQuestionData_ShouldSuccess()
        {
            //Arrange
            _quizRepositoryMock.Setup(x => x.AnyAsync(It.IsAny <ISpecification <Quiz> >()))
            .ReturnsAsync(true);
            _questionRepositoryMock.Setup(x => x.SaveAsync(It.IsAny <Question>()))
            .Callback <Question>(x => x.Id = Guid.NewGuid())
            .ReturnsAsync(true);

            var createQuestionCommand = new CreateQuestionCommand()
            {
                QuizId        = Guid.NewGuid(),
                Title         = "anonymousText",
                CorrectAnswer = "anonymousText",
                Options       = new List <Option>()
                {
                    new Option()
                    {
                        Value = "anonymousOption1"
                    },
                    new Option()
                    {
                        Value = "anonymousOption2"
                    },
                    new Option()
                    {
                        Value = "anonymousOption3"
                    },
                    new Option()
                    {
                        Value = "anonymousOption4"
                    },
                }
            };

            //Act
            var result = await _questionCommandHandler.Handle(createQuestionCommand, CancellationToken.None);

            //Assert
            Assert.NotEqual(Guid.Empty, result);
        }
Пример #2
0
        public async Task ShouldGetModelForValidInformation()
        {
            var createQuestionCommand = new CreateQuestionCommand
            {
                TenantId   = _tenantId,
                CreatedBy  = _adminUserId,
                Text       = "Asagidakilerden hangisi asagidadir?",
                Duration   = 3,
                TagsIdList = null
            };

            var questionModel = await _createQuestionCommandHandler.Handle(createQuestionCommand, CancellationToken.None);

            Assert.Null(questionModel.Errors);
        }
        public async Task Handle_GivenValidRequest_ShouldCreateQuestion()
        {
            // Arrange
            var command = new CreateQuestionCommand {
                UserId = Guid.NewGuid().ToString(), Text = "Question Text"
            };

            // Act
            var questionId = await _sut.Handle(command, CancellationToken.None);

            var result = await _context.Questions.FindAsync(questionId);

            // Assert
            Assert.NotNull(result);
        }