Esempio n. 1
0
        public void can_accept_the_property_name_and_treat_it_as_true()
        {
            PropertyInfo property = ReflectionHelper.GetProperty<DummyClass>(c => c.Hungry);
            var context = new InMemoryBindingContext();
            context["Hungry"] = "Hungry";

            ValueConverter converter = new BooleanFamily().Build(null, property);
            context.ForProperty(property, x =>
            {
                converter(context).As<bool>().ShouldBeTrue();
            });
        }
Esempio n. 2
0
        public void treats_true_string_as_true()
        {
            PropertyInfo property = ReflectionHelper.GetProperty<DummyClass>(c => c.Hungry);
            var context = new InMemoryBindingContext();
            context["Hungry"] = "true";

            ValueConverter converter = new BooleanFamily().Build(null, property);
            context.ForProperty(property, () =>
            {
                converter(context).As<bool>().ShouldBeTrue();
            });
        }
Esempio n. 3
0
        private bool WithValue(string value)
        {
            PropertyInfo property = ReflectionHelper.GetProperty<BooleanFamilyTester.DummyClass>(c => c.Hungry);
            var context = new InMemoryBindingContext();
            context["Hungry"] = value;

            var convertedValue = false;

            ValueConverter converter = new BooleanFamily().Build(null, property);
            context.ForProperty(property, x =>
            {
                convertedValue = converter(context).As<bool>();
            });

            return convertedValue;
        }