public void GetPropertyBackingField_LowercasedUnderscoreLeadingM() { // Assert var expected = typeof(SimplePoco).GetField(nameof(SimplePoco.m_byte)); // Act var actual = ExpressionExtensions.GetPropertyBackingField <SimplePoco, byte>(s => s.Byte); // Assert actual.ShouldHaveSameValueAs(expected); }
public void GetPropertyBackingField_AutoBackingField() { // Assert var expected = typeof(SimplePoco).GetField("<MyStringProperty>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); // Act var actual = ExpressionExtensions.GetPropertyBackingField <SimplePoco, string>(s => s.MyStringProperty); // Assert actual.ShouldHaveSameValueAs(expected); }
public void GetPropertyBackingField_Lowercased() { // Assert var expected = typeof(SimplePoco).GetField(nameof(SimplePoco.dateTime)); // Act var actual = ExpressionExtensions.GetPropertyBackingField <SimplePoco, DateTime>(s => s.DateTime); // Assert actual.ShouldHaveSameValueAs(expected); }
public void GetPropertyBackingField_LowercasedUnderscore() { // Assert var expected = typeof(SimplePoco).GetField(nameof(SimplePoco._myInt)); // Act var actual = ExpressionExtensions.GetPropertyBackingField <SimplePoco, int>(s => s.MyInt); // Assert actual.ShouldHaveSameValueAs(expected); }
public void GetPropertyBackingField_UnexpectedNamingConventionUsedOrMissingBackingField() { // Act ExpressionExtensions.GetPropertyBackingField <SimplePoco, object>(s => s.Object); }
public void GetPropertyBackingField_NotPropertyInfo() { // Act ExpressionExtensions.GetPropertyBackingField <SimplePoco, string>(s => s.MyStringField); }
public void GetPropertyBackingField_NotMemberExpression() { // Act ExpressionExtensions.GetPropertyBackingField <string, string>(s => s); }
public void GetPropertyBackingField_NoExpressionProvided() { // Act ExpressionExtensions.GetPropertyBackingField((Expression <Func <string, string> >)null); }