public void hash_is_repeatable()
        {
            var r1 = new RemoteFieldRule(typeof(RequiredFieldRule), accessorFor(x => x.Name));
            var r2 = new RemoteFieldRule(typeof(RequiredFieldRule), accessorFor(x => x.Name));

            r1.ToHash().ShouldEqual(r2.ToHash());
        }
        public void equality_check_negative_accessor()
        {
            var r1 = new RemoteFieldRule(typeof(RequiredFieldRule), accessorFor(x => x.Name));
            var r2 = new RemoteFieldRule(typeof(RequiredFieldRule), accessorFor(x => x.Test));

            r1.ShouldNotEqual(r2);
        }
        public RemoteFieldRule RegisterRule(Accessor accessor, IFieldValidationRule rule)
        {
            var remote = RemoteFieldRule.For(accessor, rule);

            _rules[accessor].Fill(remote);

            return(remote);
        }
Beispiel #4
0
        public Notification Run(RemoteFieldRule remote, string value)
        {
            var target  = _resolver.Resolve(remote.Accessor, value);
            var context = _validator.ContextFor(target, new Notification(target.GetType()));

            remote.Rule.Validate(remote.Accessor, context);

            return(context.Notification);
        }
        public void equality_check_negative_type()
        {
            var accessor = accessorFor(x => x.Name);

            var r1 = new RemoteFieldRule(typeof(RequiredFieldRule), accessor);
            var r2 = new RemoteFieldRule(typeof(MinimumLengthRule), accessor);

            r1.ShouldNotEqual(r2);
        }
        public void equality_check()
        {
            var accessor = accessorFor(x => x.Name);

            var r1 = new RemoteFieldRule(typeof (RequiredFieldRule), accessor);
            var r2 = new RemoteFieldRule(typeof(RequiredFieldRule), accessor);

            r1.ShouldEqual(r2);
        }
        public Notification Run(RemoteFieldRule remote, string value)
        {
            var target = _resolver.Resolve(remote.Accessor, value);
            var context = _validator.ContextFor(target, new Notification(target.GetType()));

            remote.Rule.Validate(remote.Accessor, context);

            return context.Notification;
        }
        public Notification Run(RemoteFieldRule rule, string value)
        {
            var target = _resolver.Resolve(rule.Accessor, value);
            var fieldRule = _services.GetInstance(rule.Type).As<IFieldValidationRule>();

            var context = _validator.ContextFor(target, new Notification(target.GetType()));
            fieldRule.Validate(rule.Accessor, context);

            return context.Notification;
        }
Beispiel #9
0
 public bool Equals(RemoteFieldRule other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(_rule.Equals(other._rule) && Equals(other._accessor, _accessor));
 }
        public void SetUp()
        {
            theModifier = new RemoteValidationElementModifier();
            theTag = new HtmlTag("input");

            theRequest = ElementRequest.For<RemoteTarget>(x => x.Username);
            theRequest.ReplaceTag(theTag);

            theRemoteGraph = new RemoteRuleGraph();
            theRemoteRule = theRemoteGraph.RegisterRule(theRequest.Accessor, new UniqueUsernameRule());

            theUrls = new StubUrlRegistry();

            theServices = new InMemoryServiceLocator();
            theServices.Add(theRemoteGraph);
            theServices.Add(theUrls);

            theRequest.Attach(theServices);
        }
 public bool Equals(RemoteFieldRule other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other._type == _type && Equals(other._accessor, _accessor);
 }