Exemple #1
0
        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());
        }
Exemple #2
0
        public void GetInsertQueryMethodSupports()
        {
            const string bxl   = @"class a prototype=dbtable
	string SomeField"    ;
            var          model = PersistentModel.Compile(bxl);
            var          code  = new PokoClassWriter(model["a"])
            {
                ProcessFields            = false,
                ProcessFooter            = false,
                ProcessHeader            = false,
                ProcessReferences        = false,
                ProcessHashMethods       = false,
                ProcessInsertConstructor = true
            }.ToString();

            Console.WriteLine(code);
            Assert.AreEqual(@"		/// <summary></summary>
		public string GetInsertQuery(string target = ""\""dbo\"".\""a\"""", IDictionary<string, string> additional = null) {
			var s = ""insert into "" + target + "" (\""Id\"",\""SomeField\"""";
			if (additional != null && additional.Count > 0) s += "","" + string.Join("","", additional.Keys);
s += "") values (@Id,@SomeField"";
			if (additional != null && additional.Count > 0) s += "",@"" + string.Join("",@"", additional.Values);
			s += "");"";
			return s;
		}
", code);
        }
Exemple #3
0
        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());
        }
Exemple #4
0
        public void GetHashMethodSupports()
        {
            const string bxl   = @"class a prototype=dbtable
	string SomeField hash=1"    ;
            var          model = PersistentModel.Compile(bxl);
            var          code  = new PokoClassWriter(model["a"])
            {
                ProcessFields            = false,
                ProcessFooter            = false,
                ProcessHeader            = false,
                ProcessReferences        = false,
                ProcessHashMethods       = true,
                ProcessInsertConstructor = false
            }.ToString();

            Console.WriteLine(code);
            Assert.AreEqual(@"		/// <summary>Biz hash code</summary>
		public string GetHash() {
			var src = string.Empty + SomeField + ""~"";
			return src.GetMd5();
		}
", code);
        }
Exemple #5
0
        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());
        }