public void GivenExpressionThatIsNotUnaryOrMember_SetPropertyValue_ThrowsException() { Expression <Func <TestPageType, object> > expression = page => page.IntTestProperty + 1; TestPageType typedPageData = new TestPageType(); Exception exception = Record.Exception(() => typedPageData.SetPropertyValue(expression, 1)); Assert.NotNull(exception); }
public void GivenValue_SetPropertyValue_SetsPropertyValue() { 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 valueToSet = "Test"; typedPageData.SetPropertyValue(page => page.StringTestProperty, valueToSet); Assert.Equal<string>(valueToSet, typedPageData[propertyName] as string); }
public void GivenValueOfValueType_SetPropertyValue_SetsPropertyValue() { 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()); int valueToSet = 1; typedPageData.SetPropertyValue(page => page.IntTestProperty, valueToSet); Assert.Equal <int>(valueToSet, (int)typedPageData[propertyName]); }
public void GivenValue_SetPropertyValue_SetsPropertyValue() { 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 valueToSet = "Test"; typedPageData.SetPropertyValue(page => page.StringTestProperty, valueToSet); Assert.Equal <string>(valueToSet, typedPageData[propertyName] as string); }
public void GivenExpressionThatIsNotUnaryOrMember_SetPropertyValue_ThrowsException() { Expression<Func<TestPageType, object>> expression = page => page.IntTestProperty + 1; TestPageType typedPageData = new TestPageType(); Exception exception = Record.Exception(() => typedPageData.SetPropertyValue(expression, 1)); Assert.NotNull(exception); }
public void GivenValueOfValueType_SetPropertyValue_SetsPropertyValue() { 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()); int valueToSet = 1; typedPageData.SetPropertyValue(page => page.IntTestProperty, valueToSet); Assert.Equal<int>(valueToSet, (int) typedPageData[propertyName]); }