public async Task HandleShouldReturnFailWhenDatabaseSpecificErrorOccurs()
        {
            // Arrange
            var id = Guid.NewGuid();

            var validationReadRepositoryMock = new Mock <IValidationReadRepository>();

            validationReadRepositoryMock.Setup(x => x.GetAsync(id)).Throws <SomeDatabaseSpecificException>();
            var validationReadRepository = validationReadRepositoryMock.Object;

            var mapperMock = new Mock <IMapper>();

            mapperMock.Setup(x => x.Map <ValidationModel>(It.IsAny <object>())).Returns(new ValidationModel());
            var mapper = mapperMock.Object;

            var query = new GetValidationQuery(id);

            var handler = new GetValidationQueryHandler(mapper, validationReadRepository);

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

            // Assert
            result.IsFailure.Should().BeTrue();
            result.Failures.Should().OnlyContain(x => x.Message == CustomFailures.GetValidationFailure);
        }
        public async Task HandleShouldReturnOk()
        {
            // Arrange
            var    id   = Guid.NewGuid();
            string name = "name";
            string nameOnApplication = "nameOnApplication";
            string description       = "description";
            string instruction       = "instruction";
            var    icon = new BuildingBlockIcon(Guid.NewGuid());

            var validationReadRepositoryMock = new Mock <IValidationReadRepository>();

            validationReadRepositoryMock.Setup(x => x.GetAsync(id)).Returns(Task.FromResult(new Validation(id, name, nameOnApplication, description, instruction, icon)));
            var validationReadRepository = validationReadRepositoryMock.Object;

            var mapperMock = new Mock <IMapper>();

            mapperMock.Setup(x => x.Map <ValidationModel>(It.IsAny <object>())).Returns(new ValidationModel());
            var mapper = mapperMock.Object;

            var query = new GetValidationQuery(id);

            var handler = new GetValidationQueryHandler(mapper, validationReadRepository);

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

            // Assert
            result.IsFailure.Should().BeFalse();
            result.Should().BeOfType(typeof(Result <ValidationModel>));
        }
        public async Task HandleShouldReturnFailWhenNotFound()
        {
            // Arrange
            var id = Guid.NewGuid();

            var validationReadRepositoryMock = new Mock <IValidationReadRepository>();

            validationReadRepositoryMock.Setup(x => x.GetAsync(id)).Throws <EntityNotFoundDbException>();
            var validationReadRepository = validationReadRepositoryMock.Object;

            var mapperMock = new Mock <IMapper>();

            mapperMock.Setup(x => x.Map <ValidationModel>(It.IsAny <object>())).Returns(new ValidationModel());
            var mapper = mapperMock.Object;

            var query = new GetValidationQuery(id);

            var handler = new GetValidationQueryHandler(mapper, validationReadRepository);

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

            // Assert
            result.IsFailure.Should().BeTrue();
            result.Failures.Should().OnlyContain(x => x.Code == HandlerFaultCode.NotFound.Name);
        }