예제 #1
0
        public void ExpressionReturnsMethodCall()
        {
            var newExp = InstanceToIndexExpressionMaker <Model> .Replace(0, m => m.DoSomething());

            var func   = newExp.Compile();
            var retval = func(new[] { new Model() });

            Assert.AreEqual("Call", retval);
        }
예제 #2
0
        public void ExpressionReturnsSelf()
        {
            var newExp = InstanceToIndexExpressionMaker <Model> .Replace(0, m => m);

            var func   = newExp.Compile();
            var retval = func(new[] { new Model()
                                      {
                                          Name = "Mark"
                                      } });

            Assert.AreEqual("Mark", retval.Name);
        }
예제 #3
0
        public void ExpressionUsesParentService()
        {
            var service = new SomeService();
            var newExp  = InstanceToIndexExpressionMaker <Model> .Replace(0, m => service.GetSomething(m));

            var func   = newExp.Compile();
            var retval = func(new[] { new Model()
                                      {
                                          Id = 7
                                      } });

            Assert.AreEqual(7, retval);
        }
예제 #4
0
        public void ExpressionReturnsChildProperty()
        {
            var newExp = InstanceToIndexExpressionMaker <Model> .Replace(0, m => m.Child.Name);

            var func   = newExp.Compile();
            var retval = func(new[] { new Model()
                                      {
                                          Child = new ChildModel()
                                          {
                                              Name = "Chris"
                                          }
                                      } });

            Assert.AreEqual("Chris", retval);
        }