예제 #1
0
        public void dynamic_get_property_value_throws_exception_if_key_not_provided()
        {
            var props = new DynaProps();

            props.Properties.Key = "value";
            Should.Throw <ArgumentNullException>(() => props.GetPropertyValueAs <string>(null));
            Should.Throw <ArgumentNullException>(() => props.GetPropertyValueAs <string>(string.Empty));
            Should.Throw <ArgumentNullException>(() => props.GetPropertyValueAs <string>(""));
        }
예제 #2
0
        public void dynamic_get_property_value_throws_excecption_if_can_not_convert()
        {
            var props = new DynaProps();

            props.Properties.Key = "value";
            Should.Throw <InvalidCastException>(() => props.GetPropertyValueAs <FakeType>("Key"));
        }
예제 #3
0
        public void dynamic_get_property_value_throws_exception_if_key_not_found()
        {
            var props = new DynaProps();

            props.Properties.Key = "value";
            Should.Throw <DynamicValueNotFoundException>(() => props.GetPropertyValueAs <string>("AnotheKey"));
        }
예제 #4
0
        public void dynamic_get_property_value_can_covert_between_types()
        {
            var props = new DynaProps();

            props.Properties.MyNumber = 50;
            var val = props.GetPropertyValueAs <string>("MyNumber");

            val.GetType().ShouldBe(typeof(string));
            val.Equals("50").ShouldBeTrue();
        }
예제 #5
0
        public void dynamic_get_property_value_returns_value_as_specified_type()
        {
            var props = new DynaProps();

            props.Properties.Key = "value";
            var val = props.GetPropertyValueAs <string>("Key");

            val.Equals("value").ShouldBeTrue();
            val.GetType().ShouldBe(typeof(string));
        }