public void render_data_annotations_property() { // Arrange MyMeta.ITable table = new TempTable() { Alias = "Customer" }; MyMeta.IColumn c = new StringColumn(table) { Alias = "FirstName" }; RequestContext context = new RequestContext(); context.ScriptSettings = _script; context.Zeus = new TempZeusContext(); context.Utility = new CommonUtility(); Condor.Core.Property prop = new BusinessObjectsPropertyRenderDataAnnotations(c, context); // Act prop.Render(); var expected = "[Required(ErrorMessage = \"First Name is required.\")]\r\n"; expected += "[StringLength(50, ErrorMessage=\"First Name must be between 1 and 50 characters.\")]\r\n"; expected += "[DisplayName(\"First Name\")]\r\npublic string FirstName { get; set; }\r\n\r\n"; // Assert Assert.AreEqual(expected, context.Zeus.Output.text); }
private void RenderProperties(ITable table) { Condor.Core.Property prop = null; foreach (IColumn c in table.Columns) { prop = new BusinessObjectsPropertyRenderDataAnnotations(c, _context); prop.Render(); } BusinessObjectsPropertiesRenderForeignKey foreignKey = new BusinessObjectsPropertiesRenderForeignKey(table, _context); foreignKey.Render(); }
public void BuildModelClass(ITable table, bool useWebService) { _hdrUtil.WriteClassHeader(_output); _output.autoTabLn("using System;"); _output.autoTabLn("using System.Web.Mvc;"); _output.autoTabLn("using System.ComponentModel;"); _output.autoTabLn("using System.ComponentModel.DataAnnotations;"); _output.autoTabLn("using System.Collections.Generic;"); _output.autoTabLn(""); if (useWebService) { _output.autoTabLn("using " + _script.Settings.UI.UIWcfServiceNamespace + ";"); } else { _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";"); } _output.autoTabLn(""); _output.autoTabLn("namespace " + _script.Settings.UI.UINamespace + ".Models"); _output.autoTabLn("{"); _output.tabLevel++; _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "Model"); _output.autoTabLn("{"); _output.tabLevel++; _output.autoTabLn(""); Condor.Core.Property prop = null; foreach (IColumn c in table.Columns) { prop = new BusinessObjectsPropertyRenderDataAnnotations(c, _context); prop.Render(); } BusinessObjectsPropertiesRenderForeignKey foreignKey = new BusinessObjectsPropertiesRenderForeignKey(table, _context); foreignKey.Render(); _output.autoTabLn(""); _output.tabLevel--; _output.autoTabLn("}"); _output.tabLevel--; _output.autoTabLn("}"); _context.FileList.Add(" " + StringFormatter.CleanUpClassName(table.Name) + "Model.cs"); SaveOutput(CreateFullPath(_script.Settings.UI.UINamespace + "\\Models", StringFormatter.CleanUpClassName(table.Name) + "Model.cs"), SaveActions.DontOverwrite); }