public void ExtractStringValue()
        {
            var objectHavingProperties = new HasProperties { Name = "Tester" };
            var result = this.funcOperations.ExtractValueFromInstance(objectHavingProperties, e => e.Name);

            Assert.AreEqual("Tester", result);
        }
        public void ExtractIntValue()
        {
            var objectHavingProperties = new HasProperties { Id = 10 };
            var result = this.funcOperations.ExtractValueFromInstance(objectHavingProperties, e => e.Id);

            Assert.AreEqual(10, result);
        }
 public void UseExpressionToAnalyseFunc()
 {
     var objectHavingProperties = new HasProperties { Id = 1, Name = "Tester" };
     Expression<Func<HasProperties, string>> someExpressionOfFunc = e => e.Name.Substring(0, 2);
     var expression = this.expressionOperations.ExtractInformationAboutLambdaExpression(
         objectHavingProperties, someExpressionOfFunc);
     Assert.AreEqual("e.Name.Substring(0,2)", expression);
 }
Пример #4
0
        public void ExtractIntValue()
        {
            var objectHavingProperties = new HasProperties {
                Id = 10
            };
            var result = this.funcOperations.ExtractValueFromInstance(objectHavingProperties, e => e.Id);

            Assert.AreEqual(10, result);
        }
Пример #5
0
        public void ExtractStringValue()
        {
            var objectHavingProperties = new HasProperties {
                Name = "Tester"
            };
            var result = this.funcOperations.ExtractValueFromInstance(objectHavingProperties, e => e.Name);

            Assert.AreEqual("Tester", result);
        }
        public void UseExpressionToAnalyseFunc()
        {
            var objectHavingProperties = new HasProperties {
                Id = 1, Name = "Tester"
            };
            Expression <Func <HasProperties, string> > someExpressionOfFunc = e => e.Name.Substring(0, 2);
            var expression = this.expressionOperations.ExtractInformationAboutLambdaExpression(
                objectHavingProperties, someExpressionOfFunc);

            Assert.AreEqual("e.Name.Substring(0,2)", expression);
        }
        public void UseInstanceWithLambdaFunction()
        {
            var objectHavingProperties = new HasProperties { Id = 10 };

            // Takes an instance of HasProperties as its only parameter and returns a string value.
            // We pass this function like a normal variable. This is functional programming. We
            // treat functions like values.
            Func<HasProperties, string> someLambda = e =>
                    {
                        var s = "Id + 2 = " + (e.Id + 2);
                        return s;
                    };

            var result = this.funcOperations.ExtractValueFromInstance(objectHavingProperties, someLambda);

            Assert.AreEqual("Id + 2 = 12", result);
        }
Пример #8
0
        public void UseInstanceWithLambdaFunction()
        {
            var objectHavingProperties = new HasProperties {
                Id = 10
            };

            // Takes an instance of HasProperties as its only parameter and returns a string value.
            // We pass this function like a normal variable. This is functional programming. We
            // treat functions like values.
            Func <HasProperties, string> someLambda = e =>
            {
                var s = "Id + 2 = " + (e.Id + 2);
                return(s);
            };

            var result = this.funcOperations.ExtractValueFromInstance(objectHavingProperties, someLambda);

            Assert.AreEqual("Id + 2 = 12", result);
        }