Beispiel #1
0
        public void EnsureProperty()
        {
            // Act
            var actual = ExpressionExtensions.EnsureProperty <SimplePoco, string>(s => s.MyStringProperty);

            // Assert
            Assert.IsNotNull(actual); // Not really sure how to test this?
        }
Beispiel #2
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 #3
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 #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_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 #6
0
        public void GetProperty()
        {
            // Assert
            var expected = typeof(SimplePoco).GetProperty(nameof(SimplePoco.MyStringProperty));

            // Act
            var actual = ExpressionExtensions.GetProperty <SimplePoco, string>(s => s.MyStringProperty);

            // Assert
            actual.ShouldHaveSameValueAs(expected);
        }
Beispiel #7
0
 public void GetPropertyName_NoExpressionProvided()
 {
     // Act
     ExpressionExtensions.GetPropertyName((Expression <Func <string, string> >)null);
 }
Beispiel #8
0
 public void EnsureProperty_NotPropertyInfo()
 {
     // Act
     ExpressionExtensions.EnsureProperty <SimplePoco, string>(s => s.MyStringField);
 }
Beispiel #9
0
 public void EnsureProperty_NotMemberExpression()
 {
     // Act
     ExpressionExtensions.EnsureProperty <string, string>(s => s);
 }
Beispiel #10
0
 public void EnsureProperty_NoExpressionProvided()
 {
     // Act
     ExpressionExtensions.EnsureProperty((Expression <Func <string, string> >)null);
 }
Beispiel #11
0
 public void GetPropertyBackingField_UnexpectedNamingConventionUsedOrMissingBackingField()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <SimplePoco, object>(s => s.Object);
 }
Beispiel #12
0
 public void GetPropertyBackingField_NotPropertyInfo()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <SimplePoco, string>(s => s.MyStringField);
 }
Beispiel #13
0
 public void GetPropertyBackingField_NotMemberExpression()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <string, string>(s => s);
 }
Beispiel #14
0
 public void GetPropertyBackingField_NoExpressionProvided()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField((Expression <Func <string, string> >)null);
 }
Beispiel #15
0
 public void GetPropertyName_NotMemberExpression()
 {
     // Act
     ExpressionExtensions.GetPropertyName <string, string>(s => s);
 }