public void UseMostSpecificOverride() { PropertyOrFieldNode pofNode = new PropertyOrFieldNode(); pofNode.Text = "StringProp"; Assert.AreEqual(new DateTime(2008, 1, 1), ((IExpression)pofNode).GetValue(new DerivedClass())); }
public void CanSetTransparentProxy() { PropertyOrFieldNode pofNode = new PropertyOrFieldNode(); pofNode.Text = "ObjectProp"; BaseClass ouc = new BaseClass(); TestTransparentProxyFactory tpf = new TestTransparentProxyFactory(null, typeof(ITestObject), null); object tpo = tpf.GetTransparentProxy(); Assert.IsTrue(tpo is ITestObject); ITestObject itpo = tpo as ITestObject; Assert.IsNotNull(itpo); pofNode.SetValue(ouc, null, itpo); Assert.AreSame(tpo, ouc.ObjectProp); }
public void PerformanceOfMethodEvaluationOnDifferentContextTypes() { MethodNode mn = new MethodNode(); mn.Text = "ToString"; TypeNode nln = new TypeNode(); nln.Text = "System.Globalization.CultureInfo"; PropertyOrFieldNode pn = new PropertyOrFieldNode(); pn.Text = "InvariantCulture"; Expression exp = new Expression(); exp.addChild(nln); exp.addChild(pn); StringLiteralNode sln = new StringLiteralNode(); sln.Text = "dummy"; mn.addChild(sln); mn.addChild(exp); IExpression mnExp = mn; Assert.AreEqual("dummy", mnExp.GetValue(0m, null)); int runs = 10000000; StopWatch watch = new StopWatch(); using (watch.Start("Duration: {0}")) { for (int i = 0; i < runs; i++) { mnExp.GetValue(0m, null); } } }