예제 #1
0
        public async Task ResultTrue()
        {
            var command = new DeleteQuizCommand("1");
            var handler = new DeleteQuizHandler(_mock.Object);

            var result = await handler.Handle(command, CancellationToken.None);

            Assert.AreEqual(result, true);
        }
예제 #2
0
        public async Task ResultFalse(string id)
        {
            var command = new DeleteQuizCommand(id);
            var handler = new DeleteQuizHandler(_mock.Object);

            var result = await handler.Handle(command, CancellationToken.None);

            Assert.AreEqual(result, false);
        }
예제 #3
0
        public async Task ResultNotNull()
        {
            var command = new DeleteQuizCommand("");
            var handler = new DeleteQuizHandler(_mock.Object);

            var result = await handler.Handle(command, CancellationToken.None);

            Assert.NotNull(result);
        }
예제 #4
0
        public async Task <IActionResult> DeleteQuiz(int quizId)
        {
            var command = new DeleteQuizCommand()
            {
                QuizId = quizId
            };

            await Mediator.Send(command);

            return(NoContent());
        }
예제 #5
0
        public async Task <IActionResult> DeleteQuiz(string id)
        {
            var command = new DeleteQuizCommand(id);
            var result  = await _mediator.Send(command);

            if (result)
            {
                return(Ok());
            }

            return(NotFound());
        }
예제 #6
0
        public async Task Handle_ValidQuizData_ChapterShouldNotFound()
        {
            //Arrange
            var quizId  = Guid.NewGuid();
            var command = new DeleteQuizCommand(quizId);

            _quizRepositoryMock.Setup(x => x.AnyAsync(It.IsAny <ISpecification <Quiz> >()))
            .ReturnsAsync(false);

            //Act
            //Assert
            await Assert.ThrowsAsync <InvalidOperationException>(() => _quizCommandHandler.Handle(command, CancellationToken.None));

            _autoMocker.VerifyAll();
        }
예제 #7
0
        public async Task Handle_ValidQuizData_ShouldSuccess()
        {
            //Arrange
            var quizId  = Guid.NewGuid();
            var command = new DeleteQuizCommand(quizId);

            _quizRepositoryMock.Setup(x => x.AnyAsync(It.IsAny <ISpecification <Quiz> >()))
            .ReturnsAsync(true);
            _quizRepositoryMock.Setup(x => x.DeleteAsync(It.IsAny <ISpecification <Quiz> >()))
            .ReturnsAsync(true);

            _sendEndpointProviderMock = _autoMocker.GetMock <ISendEndpointProvider>();
            _sendEndpointProviderMock.Setup(x => x.GetSendEndpoint(It.IsAny <Uri>()))
            .Returns(Task.FromResult(_sendEndpointMock.Object));

            var result = await _quizCommandHandler.Handle(command, CancellationToken.None);

            //Assert
            Assert.True(result);
            _autoMocker.VerifyAll();
        }