public void Validator_LoadingContextWhen_Success() { var entity = GetEntity(); var validator = new Validator(); var validationContext = new LoadingWhenRuleSet(GetDbAccessor().Object); var res = validator.Validate(validationContext, entity.Object, null); Assert.IsTrue(res.IsValid); }
public void Validator_ManyContexts_CorrectResult() { var entity = GetEntity(); var accountInfo = new Mock <IAccInfo>(); accountInfo.Setup(info => info.AccountType).Returns("CurrentInThirdpartyBank"); entity.Setup(p => p.AccountsInfo).Returns(accountInfo.Object); entity.Setup(x => x.Salaries).Returns(new List <ICollectionEntity>()); var validator = new Validator(); var validationContext = new LoadingDependsOnRuleSet(GetDbAccessor().Object); var validationWhenContext = new LoadingWhenRuleSet(GetDbAccessor().Object); var res = validator.ValidateMany(new IValidationRuleSet <IMainEntity>[] { validationContext, validationWhenContext }, entity.Object, null); Assert.IsTrue(res.Results.Count == 2); }