Beispiel #1
0
        public void ValidateBindInfoPasses()
        {
            var viewInstanceCreator = new DefaultViewInstanceCreator(
                (typeof(SpecifiedAttributeViewObj), new SpecifiedAttributeViewObj.ParamBinder()),
                (typeof(NoneAttributeViewObj), new NoneAttributeViewObj.ParamBinder()),
                (typeof(InvalidAttributeViewObj), new InvalidAttributeViewObj.ParamBinder())
                );

            ModelViewValidator.DoEnabled = true;

            {//Check BasicUsage
                var model    = new AppleModel();
                var bindInfo = new ModelViewBinder.BindInfo(typeof(SpecifiedAttributeViewObj));
                Assert.IsTrue(ModelViewValidator.ValidateBindInfo(model, bindInfo, viewInstanceCreator));
            }

            {//Check None Attributes
                var model    = new AppleModel();
                var bindInfo = new ModelViewBinder.BindInfo(typeof(NoneAttributeViewObj));
                Assert.IsTrue(ModelViewValidator.ValidateBindInfo(model, bindInfo, viewInstanceCreator));
            }

            {//Check Invalid Attributes
                var bindInfo = new ModelViewBinder.BindInfo(typeof(InvalidAttributeViewObj));
                var apple    = new AppleModel();
                Assert.IsFalse(ModelViewValidator.ValidateBindInfo(apple, bindInfo, viewInstanceCreator), "Invalid Model Case");

                bindInfo = new ModelViewBinder.BindInfo(
                    ModelViewBinder.BindInfo.ToID(typeof(InvalidAttributeViewObj)),
                    typeof(InvalidAttributeViewObj).FullName,
                    "invalidBinderKey");
                var orange = new OrangeModel();
                Assert.IsFalse(ModelViewValidator.ValidateBindInfo(orange, bindInfo, viewInstanceCreator), "Invalid Model Case");
            }
        }
Beispiel #2
0
        public void ParamBinderSubclassValidateBindInfoPasses()
        {
            var viewInstanceCreator = new DefaultViewInstanceCreator(
                (typeof(SpecifiedAttributeViewObj), new SpecifiedAttributeViewObjParamBinderSubClass())
                );

            ModelViewValidator.DoEnabled = true;

            var model    = new AppleModel();
            var bindInfo = new ModelViewBinder.BindInfo(typeof(SpecifiedAttributeViewObj));

            Assert.IsTrue(ModelViewValidator.ValidateBindInfo(model, bindInfo, viewInstanceCreator));
        }