Beispiel #1
0
        public async void ValidarObterResponsavel()
        {
            // Arrange
            var query = new ObterResponsavelQuery {
                Id = this.ResponsavelId
            };

            var Responsavel = new ResponsavelDto
            {
                Id    = 1,
                Nome  = "Nome",
                Cpf   = "Cpf",
                Email = "Email",
                Foto  = new byte[1]
            };

            this.mockMediator
            .Setup(m => m.Send(query, default))
            .Returns(Task.FromResult(new RequestResponseWrapper <ResponsavelDto>(true, Responsavel)));

            // Act
            var response = await this.sut.ObterResponsavelAsync(query);

            // Assert
            response.Should().BeEquivalentTo(Responsavel);
            this.mockMediator.Verify(m => m.Send(It.IsNotNull <ObterResponsavelQuery>(), default), Times.Once);
        }
        public ObterResponsavelQueryHandlerTests()
        {
            this.mockResponsavelRepository = new Mock <IResponsavelRepository>();
            this.mockNotificationContext   = new Mock <INotificationContext>();
            this.mockValidator             = new Mock <IObterResponsavelQueryValidator>();
            this.mockLogger = new Mock <ILogger <ObterResponsavelQueryHandler> >();

            this.query = new ObterResponsavelQuery {
                Id = 1
            };
            this.sut = new ObterResponsavelQueryHandler(
                this.mockResponsavelRepository.Object,
                this.mockNotificationContext.Object,
                this.mockValidator.Object,
                this.mockLogger.Object);
        }
        public async Task <ResponsavelDto> ObterResponsavelAsync(ObterResponsavelQuery query)
        {
            var result = await this.mediator.Send(query);

            return(result.Value);
        }