public Option <SuccessResult, ErrorResult> Create(CreateAccountCommand command)
 {
     return(_createAccountCommandValidator
            .Validate(command)
            .OnSuccess(errorBuilder =>
     {
         _accountRepository.Insert(_mapper.Map(command));
     }));
 }
Ejemplo n.º 2
0
        public void IsValid_ShouldBeFalse_WhenCreateAccountCommandIsNotValid()
        {
            var commandWithNullAccount = new CreateAccountCommand
            {
                MemberId      = 0,
                MemberAccount = null
            };
            var memberNewAccountDto = new MemberNewAccountDto();

            memberNewAccountDto.Name = "";
            var commandWithEmptyAccountName = new CreateAccountCommand
            {
                MemberId      = 1,
                MemberAccount = memberNewAccountDto
            };
            var validator = new CreateAccountCommandValidator();
            var result    = validator.Validate(commandWithNullAccount);
            var resultForEmptyAccountName = validator.Validate(commandWithEmptyAccountName);

            result.IsValid.ShouldBe(false);
            resultForEmptyAccountName.IsValid.ShouldBe(false);
        }