Ejemplo n.º 1
0
        public async Task GetLastQuizStatisticByQuizIdAndQuizIdHandler_NotExsistIds_ShouldArgumentNullException()
        {
            //Arrange
            var userId = Guid.NewGuid();
            var quizId = Guid.NewGuid();
            var query  = new GetQuizStatisticByUserIdQuery()
            {
                QuizId = quizId,
                UserId = userId
            };
            var handler = _autoMocker.CreateInstance <GetQuizStatisticByUserIdQueryHandler>();

            _quizStatisticRepositoryMock.Setup(x => x.GetAllAsync(It.IsAny <ISpecification <QuizStatistic> >()))
            .ReturnsAsync(default(List <QuizStatistic>));
            //Act
            var result = await Assert.ThrowsAsync <ArgumentNullException>(() => handler.Handle(query, CancellationToken.None));

            //Assert
            Assert.Contains($"Quiz statistic for quiz id {quizId} and user id {userId} not found", result.Message);
        }
Ejemplo n.º 2
0
        public async Task GetLastQuizStatisticByQuizIdAndQuizIdHandler_ExsistIds_ShouldSuccess()
        {
            //Arrange
            var userId = Guid.NewGuid();
            var quizId = Guid.NewGuid();
            var query  = new GetQuizStatisticByUserIdQuery()
            {
                QuizId = quizId,
                UserId = userId
            };
            var handler = _autoMocker.CreateInstance <GetQuizStatisticByUserIdQueryHandler>();

            _quizStatisticRepositoryMock.Setup(x => x.GetAllAsync(It.IsAny <ISpecification <QuizStatistic> >()))
            .ReturnsAsync(GetQuizStatisticList(quizId));
            _quizStatisticServiceMock.Setup(x => x.GetQuizStatistic(It.IsAny <QuizStatistic>()))
            .Returns(GetQuizStatisticView());

            //Act
            var result = await handler.Handle(query, CancellationToken.None);

            //Assert
            Assert.NotNull(result);
        }