Exemplo n.º 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?
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public void GetPropertyName_NoExpressionProvided()
 {
     // Act
     ExpressionExtensions.GetPropertyName((Expression <Func <string, string> >)null);
 }
Exemplo n.º 8
0
 public void EnsureProperty_NotPropertyInfo()
 {
     // Act
     ExpressionExtensions.EnsureProperty <SimplePoco, string>(s => s.MyStringField);
 }
Exemplo n.º 9
0
 public void EnsureProperty_NotMemberExpression()
 {
     // Act
     ExpressionExtensions.EnsureProperty <string, string>(s => s);
 }
Exemplo n.º 10
0
 public void EnsureProperty_NoExpressionProvided()
 {
     // Act
     ExpressionExtensions.EnsureProperty((Expression <Func <string, string> >)null);
 }
Exemplo n.º 11
0
 public void GetPropertyBackingField_UnexpectedNamingConventionUsedOrMissingBackingField()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <SimplePoco, object>(s => s.Object);
 }
Exemplo n.º 12
0
 public void GetPropertyBackingField_NotPropertyInfo()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <SimplePoco, string>(s => s.MyStringField);
 }
Exemplo n.º 13
0
 public void GetPropertyBackingField_NotMemberExpression()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField <string, string>(s => s);
 }
Exemplo n.º 14
0
 public void GetPropertyBackingField_NoExpressionProvided()
 {
     // Act
     ExpressionExtensions.GetPropertyBackingField((Expression <Func <string, string> >)null);
 }
Exemplo n.º 15
0
 public void GetPropertyName_NotMemberExpression()
 {
     // Act
     ExpressionExtensions.GetPropertyName <string, string>(s => s);
 }