public void Condition_IsNull_NoCodeAppears() { string srcFieldName = "x"; string destFieldName = "y"; var propertyMap = CreatePropertyMap <A, B>("P1", "P1"); var context = new PropertyNameContext(propertyMap); var coder = new Recorder(); using (var condition = new ConditionPrinter(context, coder)) { } Assert.IsNullOrEmpty(coder.ToAssignment().RelativeTemplate); }
public void Condition_IsNotNull_PrintCode() { string srcFieldName = "x"; string destFieldName = "y"; var propertyMap = CreatePropertyMap <A, B>("P1", "P1"); var context = new PropertyNameContext(propertyMap); var coder = new Recorder(); Expression <Func <A, bool> > exp = src => src.P1 != 0; propertyMap.OriginalCondition = new OriginalStatement(exp); using (var condition = new ConditionPrinter(context, coder)) { } string template = coder.ToAssignment().RelativeTemplate.Replace(Environment.NewLine, ""); Assert.AreEqual("if ({0}.P1 != 0){{}}", template); }