protected FakeValidationStrategy(Type type) { SourceType = type ?? throw new ArgumentNullException(nameof(type)); _memberValueRuleBuilders = new List <FakeValueRuleBuilder>(); _contract = VerifiableObjectContractManager.Resolve(type); }
protected FakeValidationStrategy() { SourceType = typeof(T); _memberValueRuleBuilders = new List <FakeValueRuleBuilder <T> >(); _contract = VerifiableObjectContractManager.Resolve <T>(); }
public override VerifiableObjectContext Resolve(Type declaringType, IDictionary <string, object> keyValueCollection) { var handler = MemberHandlerResolver.Resolve(declaringType); var impl = new MemberObjectContractImpl(handler); var contract = new VerifiableObjectContract(impl); return(contract.WithDictionary(keyValueCollection)); }
public override VerifiableObjectContext Resolve <T>(IDictionary <string, object> keyValueCollection, string instanceName) { var handler = MemberHandlerResolver.Resolve <T>(); var impl = new MemberObjectContractImpl(handler); var contract = new VerifiableObjectContract(impl); return(contract.WithDictionary(keyValueCollection, instanceName)); }
public FluentValidationRegistrar(Type type, string name, IValidationRegistrar parentRegistrar) { _name = name; SourceType = type; _parentRegistrar = parentRegistrar ?? throw new ArgumentNullException(nameof(parentRegistrar)); _verifiableObjectContract = VerifiableObjectContractManager.Resolve(type); Rules = new List <CorrectValueRule>(); }
public void ImplForVerifiableObjectContractTest() { var objImpl = new LocalObjectContractImpl(); var objContract = new VerifiableObjectContract(objImpl); objContract.GetValue((object)null, "Name").ShouldBe("Nice"); objContract.GetValue((object)null, "Length").ShouldBe(10); objContract.GetValue((object)null, "Width").ShouldBe(100); }
public override VerifiableObjectContext Resolve <T>(T instance) { if (instance is VerifiableObjectContext objectContext) { return(objectContext); } if (instance is VerifiableMemberContext memberContext) { return(memberContext.ConvertToObjectContext()); } var handler = MemberHandlerResolver.Resolve <T>(); var impl = new MemberObjectContractImpl(handler); var contract = new VerifiableObjectContract(impl); return(contract.WithInstance(instance)); }
public override VerifiableObjectContext Resolve(Type declaringType, object instance, string instanceName) { if (instance is VerifiableObjectContext objectContext) { return(objectContext); } if (instance is VerifiableMemberContext memberContext) { return(memberContext.ConvertToObjectContext()); } var handler = MemberHandlerResolver.Resolve(declaringType); var impl = new MemberObjectContractImpl(handler); var contract = new VerifiableObjectContract(impl); return(contract.WithInstance(instance, instanceName)); }