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()); }
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()); }
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()); }