public async Task RegisterSpeechWithValidModelStateReturnOk()
        {
            //Arrange
            RegisterSpeechCommandMessage registerSpeechCommandMessage = null;
            var moqRegisterSpeechUseCase = new Mock <IRegisterSpeechUseCase>();

            moqRegisterSpeechUseCase.Setup(x => x.Handle(It.IsAny <RegisterSpeechCommandMessage>()))
            .Returns(Task.CompletedTask)
            .Callback <RegisterSpeechCommandMessage>(x => registerSpeechCommandMessage = x);
            var moqUpdateSpeechUseCase = new Mock <IUpdateSpeechUseCase>();
            var speechForCreationDto   = new SpeechForCreationDto
            {
                Title       = "is simply dummy text of the printing",
                Description =
                    @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
                                text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged",
                Type = "1",
                Url  = "http://myjpg.jpg",
            };

            var sut = new SpeechController(moqRegisterSpeechUseCase.Object, moqUpdateSpeechUseCase.Object);

            //Act
            IActionResult result = await sut.Post(speechForCreationDto);

            //Assert
            Assert.IsType <OkResult>(result);
            moqRegisterSpeechUseCase.Verify(x => x.Handle(It.IsAny <RegisterSpeechCommandMessage>()), Times.Once);
            Assert.Equal(speechForCreationDto.Title, registerSpeechCommandMessage.Title);
            Assert.Equal(speechForCreationDto.Description, registerSpeechCommandMessage.Description);
            Assert.Equal(speechForCreationDto.Type, registerSpeechCommandMessage.Type);
            Assert.Equal(speechForCreationDto.Url, registerSpeechCommandMessage.Url);
        }
Exemple #2
0
        public async Task RegisterSpeechWithInvalidModelStateReturnBadRequest()
        {
            //Arrange
            var moq = new Mock <IRegisterSpeechUseCase>();
            var sut = new SpeechController(moq.Object);

            sut.ModelState.AddModelError("x", "Invalid ModelState");

            //Act
            IActionResult result = await sut.Post(It.IsAny <SpeechForCreationDto>());

            //Assert
            Assert.IsType <BadRequestObjectResult>(result);
        }