Exemplo n.º 1
0
        public void CreatePropertyInfoPropertyValueGetter_NullProperty_NullGetter()
        {
            var fakeName = new FakeName {
                First = "Firstie", Last = "Lastly"
            };
            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(fakeName, null);

            Assert.Null(getter);
        }
Exemplo n.º 2
0
        public void CreatePropertyInfoPropertyValueGetter_PropertyDoesNotExistOnInstnace_NullGetterCreated()
        {
            var fakeName = new FakeName {
                First = "Thor", Last = "Jenkins"
            };
            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(fakeName, "DoesNotExist");

            Assert.Null(getter);
        }
Exemplo n.º 3
0
        public void CreatePropertyInfoPropertyValueGetter_EmptyStringProperty_NullGetter()
        {
            const string propertyName = "";

            var fakeName = new FakeName {
                First = "Firstie", Last = "Lastly"
            };

            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(fakeName, propertyName.ToLower());

            Assert.Null(getter);
        }
Exemplo n.º 4
0
        public void CreatePropertyInfoPropertyValueGetter_NonDynamicInstance_ValidGetterCreated()
        {
            const string firstProperty = "First";
            const string firstName     = "John";

            var fakeName = new FakeName {
                First = firstName, Last = "Doe"
            };
            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(fakeName, firstProperty);

            Assert.Equal(firstProperty, getter.PropertyName);
            Assert.Equal(firstName, getter.GetPropertyValue(fakeName));
        }
Exemplo n.º 5
0
        public void CreatePropertyInfoPropertyValueGetter_PropertyCaseDoesNotMatch_ValidGetterCreated()
        {
            const string firstProperty = "fIRsT";
            const string firstName     = "John";

            var fakeName = new FakeName {
                First = firstName, Last = "Doe"
            };

            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(fakeName, firstProperty);

            Assert.Equal("First", getter.PropertyName);
            Assert.Equal(firstName, getter.GetPropertyValue(fakeName));
        }
Exemplo n.º 6
0
        public void GetPropertyValue_NullInstance_RuntimeBinderException()
        {
            const string propertyName = "First";

            var fakeName = new FakeName {
                First = "Hank", Last = "The Tank"
            };

            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(fakeName, propertyName);

            Assert.Throws <ArgumentNullException>(
                () =>
                getter.GetPropertyValue(null)
                );
        }
Exemplo n.º 7
0
        public void GetPropertyValue_PropertyDoesNotExistOnInstance_TargetException()
        {
            const string propertyName = "First";

            var fakeName = new FakeName {
                First = "Thor", Last = "Jenkins"
            };

            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(fakeName, propertyName);

            var fakeLink = new FakeLink {
                Rel = "self", Uri = "http://localhost/"
            };

            Assert.Throws <TargetException>(
                () =>
                getter.GetPropertyValue(fakeLink)
                );
        }
Exemplo n.º 8
0
        public void CreatePropertyInfoPropertyValueGetter_NullInstanceNullProperty_NullGetter()
        {
            var getter = PropertyInfoPropertyValueGetter.CreatePropertyInfoPropertyValueGetter(null, null);

            Assert.Null(getter);
        }