示例#1
0
        public void FromLambdaExpression_ModelSelfTest()
        {
            TestParticipantClass tpc = new TestParticipantClass();
            Expression <Func <TestParticipantClass, TestParticipantClass> > expression = p => p;

            ModelMetaData mmd = ModelMetaData.FromLambdaExpression(expression, tpc);

            Assert.AreEqual("", mmd.PropertyName);
            Assert.AreEqual(true, mmd.IsSelf);
            Assert.AreEqual(tpc, mmd.ModelAccessor());
        }
示例#2
0
        public void FromLambdaExpression_StringProperty()
        {
            TestParticipantClass tpc = new TestParticipantClass();

            tpc.FirstName = "Michael";
            Expression <Func <TestParticipantClass, String> > expression = p => p.FirstName;

            ModelMetaData mmd = ModelMetaData.FromLambdaExpression(expression, tpc);

            Assert.AreEqual("FirstName", mmd.PropertyName);
            Assert.AreEqual(false, mmd.IsSelf);
            Assert.AreEqual(tpc.FirstName, mmd.ModelAccessor());
        }
示例#3
0
        public void FromLambdaExpression_ChildObject()
        {
            TestParticipantClass tpc = new TestParticipantClass();
            Expression <Func <TestParticipantClass, TestParticipantAddressClass> > expression = p => p.Address;

            ModelMetaData mmd = ModelMetaData.FromLambdaExpression(expression, tpc);

            Assert.AreEqual("Address", mmd.PropertyName);
            Assert.AreEqual(false, mmd.IsSelf);
            Assert.AreEqual(tpc.Address, mmd.ModelAccessor());

            tpc.Address = new TestParticipantAddressClass();
            mmd         = ModelMetaData.FromLambdaExpression(expression, tpc);
            Assert.AreEqual("Address", mmd.PropertyName);
            Assert.AreEqual(false, mmd.IsSelf);
            Assert.AreEqual(tpc.Address, mmd.ModelAccessor());
        }