Exemplo n.º 1
0
        public async Task UseCaseBase_WhenRequestIsInvalid_ReturnValidateError()
        {
            var logger    = new Mock <ILogger <SpecificUseCase> >().Object;
            var validator = ValidatorFactory.GetInValidValidator <int>("mockCode");

            var useCase  = new SpecificUseCase(logger, validator);
            var response = await useCase.Execute(5);

            response.Status.Should().Be(UseCaseResponseStatus.ValidateError);
            response.Success().Should().BeFalse();
            response.Errors
            .Should().NotBeNullOrEmpty()
            .And.ContainSingle(x => x.Code == "mockCode");
        }
Exemplo n.º 2
0
        public async Task UseCaseBase_WhenThrowsAnException_Returnerror()
        {
            //Given
            var logger    = new Mock <ILogger <SpecificUseCase> >().Object;
            var validator = ValidatorFactory.GetValidValidator <int>();

            //When
            var useCase  = new SpecificUseCase(logger, validator);
            var response = await useCase.Execute(0);

            //Then
            response.Status.Should().Be(UseCaseResponseStatus.ExceptionError);
            response.Success().Should().BeFalse();
            response.Errors
            .Should().NotBeNullOrEmpty()
            .And.ContainSingle(x => x.Code == "errorCode");
        }