Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public void GetPropertyBackingField_UnexpectedNamingConventionUsedOrMissingBackingField()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <SimplePoco, object>(s => s.Object);
 }
Beispiel #6
0
 public void GetPropertyBackingField_NotPropertyInfo()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <SimplePoco, string>(s => s.MyStringField);
 }
Beispiel #7
0
 public void GetPropertyBackingField_NotMemberExpression()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <string, string>(s => s);
 }
Beispiel #8
0
 public void GetPropertyBackingField_NoExpressionProvided()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField((Expression <Func <string, string> >)null);
 }