public static (bool isValid, IEnumerable <IValidationResult> errors) IsValid(this IMigrationSet set)
        {
            var errors = new List <IValidationResult>();

            bool isValidSet = set.Info != null && set.Entities != null;

            if (isValidSet == false)
            {
                return(false, errors);
            }

            var isValidInfo = set.Info.IsValid();

            switch (set.Info?.Type)
            {
            case MigrationType.ChartOfAccount:
            {
                var validation = new AccountValidation();
                return(Validate(validation, set.Entities.Cast <IAccount>(), isValidInfo));
            }

            case MigrationType.Journal:
            {
                var validation = new JournalValidation();
                return(Validate(validation, set.Entities.Cast <IJournal>(), isValidInfo));
            }

            case MigrationType.InputInvoice:
            {
                var validation = new InputInvoiceValidation();
                return(Validate(validation, set.Entities.Cast <IInputInvoice>(), isValidInfo));
            }

            case MigrationType.OutputInvoice:
            {
                var validation = new OutputInvoiceValidation();
                return(Validate(validation, set.Entities.Cast <IOutputInvoice>(), isValidInfo));
            }

            case MigrationType.None:
                return(false, errors);

            default:
                return(false, errors);
            }
        }
Beispiel #2
0
 public JournalValidationsTests()
 {
     this.validation = new JournalValidation();
 }