public void DefaultCSharpValueTest() { var model = PersistentModel.Compile(@" class a prototype=dbtable datetime Date ""DateTime"" csharp-default='Qorpent.QorpentConst.Date.End' "); var code = new PokoClassWriter(model["a"]) { WithHeader = false, ProcessReferences = false, ProcessInsertConstructor = false }.ToString().Replace("\"", "\"\""); Console.WriteLine(code); Assert.AreEqual(@" using System; using System.Collections.Generic; #if !NOQORPENT using Qorpent.Serialization; using Qorpent.Model; using Qorpent.Utils.Extensions; #endif namespace { ///<summary> /// ///</summary> #if !NOQORPENT [Serialize] #endif public partial class a { ///<summary>Lazy load nest type</summary> public class Lazy:a{ ///<summary>Function to get lazy</summary> public Func<a,a> GetLazy; } ///<summary> /// ///</summary> #if !NOQORPENT [SerializeNotNullOnly] #endif public virtual Int32 Id {get {return NativeId;} set{NativeId=value;}} ///<summary>Direct access to Id</summary> protected Int32 NativeId; ///<summary> ///DateTime ///</summary> #if !NOQORPENT [SerializeNotNullOnly] #endif public virtual System.DateTime Date {get {return NativeDate;} set{NativeDate=value;}} ///<summary>Direct access to Date</summary> protected System.DateTime NativeDate = Qorpent.QorpentConst.Date.End; } }".Trim().LfOnly(), code.Trim().LfOnly()); }
public void ImplementsAndHideSupport() { var model = PersistentModel.Compile(@" class a prototype=dbtable implements IMyInterface string Code Код hide=IMyInterface "); var code = new PokoClassWriter(model["a"]) { WithHeader = false, ProcessInsertConstructor = false }.ToString().Replace("\"", "\"\""); Console.WriteLine(code); Assert.AreEqual(@" using System; using System.Collections.Generic; #if !NOQORPENT using Qorpent.Serialization; using Qorpent.Model; using Qorpent.Utils.Extensions; #endif namespace { ///<summary> /// ///</summary> #if !NOQORPENT [Serialize] #endif public partial class a : IMyInterface { ///<summary>Lazy load nest type</summary> public class Lazy:a{ ///<summary>Function to get lazy</summary> public Func<a,a> GetLazy; } ///<summary> /// ///</summary> #if !NOQORPENT [SerializeNotNullOnly] #endif public virtual Int32 Id {get {return NativeId;} set{NativeId=value;}} ///<summary>Direct access to Id</summary> protected Int32 NativeId; } } ".Trim().LfOnly(), code.Trim().LfOnly()); }
public void ReferenceSupport() { var model = PersistentModel.Compile(@" class a prototype=dbtable ref b class b prototype=dbtable "); var code = new PokoClassWriter(model["a"]) { WithHeader = false, ProcessInsertConstructor = false }.ToString().Replace("\"", "\"\""); Console.WriteLine(code); Assert.AreEqual(@" using System; using System.Collections.Generic; #if !NOQORPENT using Qorpent.Serialization; using Qorpent.Model; using Qorpent.Utils.Extensions; #endif namespace { ///<summary> /// ///</summary> #if !NOQORPENT [Serialize] #endif public partial class a { ///<summary>Lazy load nest type</summary> public class Lazy:a{ ///<summary>Function to get lazy</summary> public Func<a,a> GetLazy; } ///<summary> /// ///</summary> #if !NOQORPENT [SerializeNotNullOnly] #endif public virtual Int32 Id {get {return NativeId;} set{NativeId=value;}} ///<summary>Direct access to Id</summary> protected Int32 NativeId; ///<summary> /// (Идентификатор) ///</summary> #if !NOQORPENT [SerializeNotNullOnly] #endif public virtual Int32 bId {get {return NativebId;} set{NativebId=value;}} ///<summary>Direct access to bId</summary> protected Int32 NativebId; ///<summary> /// ///</summary> #if !NOQORPENT [SerializeNotNullOnly] #endif public virtual b b {get {return ((null!=Nativeb as b.Lazy )?( Nativeb = ((b.Lazy) Nativeb ).GetLazy(Nativeb) ): Nativeb );} set{Nativeb=value;}} ///<summary>Direct access to b</summary> protected b Nativeb; } } ".Trim().LfOnly(), code.Trim().LfOnly()); }