Ejemplo n.º 1
0
                public void ThrowsExceptionWhenKeyIsEmptyString()
                {
                    var props = new ObjectWithProperties();

                    props.Properties["Key"] = "value";

                    Should.Throw <ArgumentException>(() => props.GetPropertyValueAs <string>(string.Empty));
                    Should.Throw <ArgumentException>(() => props.GetPropertyValueAs <string>(""));
                }
Ejemplo n.º 2
0
                public void ThrowsExcecptionWhenCanNotConvert()
                {
                    var props = new ObjectWithProperties();

                    props.Properties["Key"] = "value";
                    Should.Throw <InvalidCastException>(() => props.GetPropertyValueAs <FakeType>("Key"));
                }
Ejemplo n.º 3
0
                public void ThrowsExceptionWhenKeyIsNotFound()
                {
                    var props = new ObjectWithProperties();

                    props.Properties["Key"] = "value";

                    Should.Throw <DynamicValueNotFoundException>(() => props.GetPropertyValueAs <string>("AnotheKey"));
                }
Ejemplo n.º 4
0
                public void ThrowsExceptionWhenKeyIsNull()
                {
                    var props = new ObjectWithProperties();

                    props.Properties["Key"] = "value";

                    Should.Throw <ArgumentNullException>(() => props.GetPropertyValueAs <string>(null));
                }
Ejemplo n.º 5
0
                public void CovertsBetweenTypes()
                {
                    var props = new ObjectWithProperties();

                    props.Properties["MyNumber"] = 50;

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

                    val.GetType().ShouldBe(typeof(string));
                    val.Equals("50").ShouldBeTrue();
                }
Ejemplo n.º 6
0
                public void ReturnsValueAsSpecifiedType()
                {
                    var props = new ObjectWithProperties();

                    props.Properties["Key"] = "value";

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

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