public void GivenExpressionThatIsNotUnaryOrMember_GetPropertyValue_ThrowsException()
        {
            Expression <Func <TestPageType, object> > expression = page => page.IntTestProperty + 1;
            TestPageType typedPageData = new TestPageType();

            Exception exception = Record.Exception(() => typedPageData.GetPropertyValue(expression));

            Assert.NotNull(exception);
        }
        public void GivenPropertyIsValueTypeAndNull_GetPropertyValue_ThrowsException()
        {
            Expression<Func<TestPageType, int>> expression = page => page.IntTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string propertyName = methodExpression.Member.Name;
            TestPageType typedPageData = new TestPageType();
            typedPageData.Property.Add(propertyName, new PropertyNumber());

            Exception exception = Record.Exception(() => typedPageData.GetPropertyValue(page => page.IntTestProperty));

            Assert.NotNull(exception);
        }
        public void GivenPropertyIsReferenceTypeAndNull_GetPropertyValue_ReturnsNull()
        {
            Expression<Func<TestPageType, string>> expression = page => page.StringTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string propertyName = methodExpression.Member.Name;
            TestPageType typedPageData = new TestPageType();
            typedPageData.Property.Add(propertyName, new PropertyString());

            string returnedValue = typedPageData.GetPropertyValue(page => page.StringTestProperty);

            Assert.Null(returnedValue);
        }
        public void GivenPropertyIsNullableTypeAndNull_GetPropertyValue_ReturnsNullValue()
        {
            Expression<Func<TestPageType, int?>> expression = page => page.NullableIntTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string propertyName = methodExpression.Member.Name;
            TestPageType typedPageData = new TestPageType();
            typedPageData.Property.Add(propertyName, new PropertyNumber());

            int? returnedValue = typedPageData.GetPropertyValue(page => page.NullableIntTestProperty);

            Assert.False(returnedValue.HasValue);
        }
        public void GivenPropertyIsValueTypeAndNull_GetPropertyValue_ThrowsException()
        {
            Expression <Func <TestPageType, int> > expression = page => page.IntTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string           propertyName     = methodExpression.Member.Name;
            TestPageType     typedPageData    = new TestPageType();

            typedPageData.Property.Add(propertyName, new PropertyNumber());

            Exception exception = Record.Exception(() => typedPageData.GetPropertyValue(page => page.IntTestProperty));

            Assert.NotNull(exception);
        }
        public void GivenPropertyIsNullableTypeAndNull_GetPropertyValue_ReturnsNullValue()
        {
            Expression <Func <TestPageType, int?> > expression = page => page.NullableIntTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string           propertyName     = methodExpression.Member.Name;
            TestPageType     typedPageData    = new TestPageType();

            typedPageData.Property.Add(propertyName, new PropertyNumber());

            int?returnedValue = typedPageData.GetPropertyValue(page => page.NullableIntTestProperty);

            Assert.False(returnedValue.HasValue);
        }
        public void GivenPropertyIsReferenceTypeAndNull_GetPropertyValue_ReturnsNull()
        {
            Expression <Func <TestPageType, string> > expression = page => page.StringTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string           propertyName     = methodExpression.Member.Name;
            TestPageType     typedPageData    = new TestPageType();

            typedPageData.Property.Add(propertyName, new PropertyString());

            string returnedValue = typedPageData.GetPropertyValue(page => page.StringTestProperty);

            Assert.Null(returnedValue);
        }
        public void GivenPropertyValueIsValueType_GetPropertyValue_ReturnsPropertyValue()
        {
            Expression <Func <TestPageType, int> > expression = page => page.IntTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string           propertyName     = methodExpression.Member.Name;
            TestPageType     typedPageData    = new TestPageType();
            int propertyValue = 1;

            typedPageData.Property.Add(propertyName, new PropertyNumber(propertyValue));


            int returnedValue = typedPageData.GetPropertyValue(page => page.IntTestProperty);

            Assert.Equal <int>(propertyValue, returnedValue);
        }
        public void GetPropertyValue_ReturnsPropertyValue()
        {
            Expression<Func<TestPageType, string>> expression = page => page.StringTestProperty;
            
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string propertyName = methodExpression.Member.Name;
            TestPageType typedPageData = new TestPageType();
            string propertyValue = "Test";
            typedPageData.Property.Add(propertyName, new PropertyString(propertyValue));
            

            string returnedValue = typedPageData.GetPropertyValue(page => page.StringTestProperty);

            Assert.Equal<string>(propertyValue, returnedValue);
        }
        public void GetPropertyValue_ReturnsPropertyValue()
        {
            Expression <Func <TestPageType, string> > expression = page => page.StringTestProperty;

            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string           propertyName     = methodExpression.Member.Name;
            TestPageType     typedPageData    = new TestPageType();
            string           propertyValue    = "Test";

            typedPageData.Property.Add(propertyName, new PropertyString(propertyValue));

            string returnedValue = typedPageData.GetPropertyValue(page => page.StringTestProperty);

            Assert.Equal <string>(propertyValue, returnedValue);
        }
        public void GivenOtherReturnTypeThanPropertyTypeAndValueExistsAndIncludeDynamicIsTrue_GetPropertyValue_ReturnsPropertyValue1()
        {
            Expression <Func <TestPageType, int?> > expression = page => page.NullableIntTestProperty;

            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string           propertyName     = methodExpression.Member.Name;
            TestPageType     typedPageData    = new TestPageType();
            int?propertyValue = 1;

            typedPageData.Property.Add(propertyName, new PropertyNumber(propertyValue.Value));


            int returnedValue = typedPageData.GetPropertyValue <TestPageType, int>(page => page.NullableIntTestProperty, true);

            Assert.Equal <int>(propertyValue.Value, returnedValue);
        }
        public void GivenExpressionThatIsNotUnaryOrMember_GetPropertyValue_ThrowsException()
        {
            Expression<Func<TestPageType, object>> expression = page => page.IntTestProperty + 1;
            TestPageType typedPageData = new TestPageType();

            Exception exception = Record.Exception(() => typedPageData.GetPropertyValue(expression));

            Assert.NotNull(exception);
        }
        public void GivenPropertyValueIsValueType_GetPropertyValue_ReturnsPropertyValue()
        {
            Expression<Func<TestPageType, int>> expression = page => page.IntTestProperty;
            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string propertyName = methodExpression.Member.Name;
            TestPageType typedPageData = new TestPageType();
            int propertyValue = 1;
            typedPageData.Property.Add(propertyName, new PropertyNumber(propertyValue));


            int returnedValue = typedPageData.GetPropertyValue(page => page.IntTestProperty);

            Assert.Equal<int>(propertyValue, returnedValue);
        }
        public void GivenOtherReturnTypeThanPropertyTypeAndValueExistsAndIncludeDynamicIsTrue_GetPropertyValue_ReturnsPropertyValue1()
        {
            Expression<Func<TestPageType, int?>> expression = page => page.NullableIntTestProperty;

            MemberExpression methodExpression = (MemberExpression)expression.Body;
            string propertyName = methodExpression.Member.Name;
            TestPageType typedPageData = new TestPageType();
            int? propertyValue = 1;
            typedPageData.Property.Add(propertyName, new PropertyNumber(propertyValue.Value));


            int returnedValue = typedPageData.GetPropertyValue<TestPageType, int>(page => page.NullableIntTestProperty, true);

            Assert.Equal<int>(propertyValue.Value, returnedValue);
        }