public void NewTargetClassWithLabel_ShouldCreateNewTargetClassWithLabel() { SourceWebPage sourceWebPage = new SourceWebPage { ClassFullName = "Test1.TestSourceClass", PageUrl = "TestSourceClass.aspx", Controls = new List <SourceWebControl>() { new SourceWebControl { ClassFullName = "System.Web.UI.WebControls.Label", FieldName = "TestTargetField" } } }; TargetClass targetClass = new TargetClass(); var targetModelGenerator = new TargetModelGenerator(); targetClass = targetModelGenerator.UpdateClass(sourceWebPage, targetClass); Assert.AreEqual(1, targetClass.TargetFieldList.Count); TestValidators.ValidateTargetField(targetClass.TargetFieldList[0], isDirty: true, sourceClassFullName: "System.Web.UI.WebControls.Label", sourceFieldName: "TestTargetField", targetControlType: EnumTargetControlType.Label, targetFieldName: "TestTargetField"); }
public void ExistingClassExistingIrrelevantFields() { SourceWebPage sourceWebPage = new SourceWebPage { ClassFullName = "Test1.TestSourceClass", PageUrl = "TestSourceClass.aspx", Controls = new List <SourceWebControl>() { new SourceWebControl { ClassFullName = "System.Web.UI.WebControls.HyperLink", FieldName = "NewTargetField" } } }; var targetClass = new TargetClass() { TargetFieldList = new List <TargetField>() { new TargetField { IsDirty = false, SourceClassFullName = "TestSourcenamespace.TestSourceClass", SourceFieldName = "ExistingTargetField", TargetControlType = EnumTargetControlType.Unknown, TargetFieldName = "ExistingTargetFieldName" } } }; var targetModelGenerator = new TargetModelGenerator(); targetClass = targetModelGenerator.UpdateClass(sourceWebPage, targetClass); Assert.AreEqual(2, targetClass.TargetFieldList.Count); TestValidators.ValidateTargetField(targetClass.TargetFieldList[0], isDirty: false, sourceClassFullName: "TestSourcenamespace.TestSourceClass", sourceFieldName: "ExistingTargetField", targetControlType: EnumTargetControlType.Unknown, targetFieldName: "ExistingTargetFieldName"); TestValidators.ValidateTargetField(targetClass.TargetFieldList[1], isDirty: true, sourceClassFullName: "System.Web.UI.WebControls.HyperLink", sourceFieldName: "NewTargetField", targetControlType: EnumTargetControlType.Link, targetFieldName: "NewTargetField"); }
public void ExistingClassChangedTargetFieldType_ShouldUpdateTargetFieldType() { SourceWebPage sourceWebPage = new SourceWebPage { ClassFullName = "Test1.TestSourceClass", PageUrl = "TestSourceClass.aspx", Controls = new List <SourceWebControl>() { new SourceWebControl { ClassFullName = typeof(System.Web.UI.WebControls.HyperLink).FullName, FieldName = "TestTargetField" } } }; var targetClass = new TargetClass() { TargetFieldList = new List <TargetField>() { new TargetField { IsDirty = false, SourceClassFullName = typeof(System.Web.UI.WebControls.HyperLink).FullName, SourceFieldName = "TestTargetField", TargetControlType = EnumTargetControlType.TextBox, TargetFieldName = "TestTargetField" } } }; var targetModelGenerator = new TargetModelGenerator(); targetClass = targetModelGenerator.UpdateClass(sourceWebPage, targetClass); Assert.AreEqual(1, targetClass.TargetFieldList.Count); TestValidators.ValidateTargetField(targetClass.TargetFieldList[0], isDirty: true, sourceClassFullName: typeof(System.Web.UI.WebControls.HyperLink).FullName, sourceFieldName: "TestTargetField", targetControlType: EnumTargetControlType.Link, targetFieldName: "TestTargetField"); }