| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System.ComponentModel.DataAnnotations.Schema;
- using qdr.fnd.core.test;
- using Quadarax.Application.QLiberace.Base.Entities;
- using Quadarax.Application.QLiberace.Common.Entities.Base;
- using Quadarax.Foundation.Core.Reflection;
- namespace Quadarax.Application.QLiberace.Base.Tests.Entities.Base
- {
- public abstract class BaseDaoTest<TDao> : DaoTest<TDao, long> where TDao : QlbrcEntityWithId
- {
- protected void CheckHasTracked(string customMessage)
- {
- if (string.IsNullOrEmpty(customMessage))
- customMessage = "Has no ITracked implemented";
- Assert.IsTrue(typeof(TDao).IsAssignableTo(typeof(ITracked)), customMessage);
- }
- protected void CheckClassTable(string customMessage)
- {
- if (string.IsNullOrEmpty(customMessage))
- customMessage = "Has no Table attribute";
- Assert.IsTrue(AttributeQuery<TableAttribute>.Has(typeof(TDao)), customMessage);
- var attr = AttributeQuery<TableAttribute>.Get(typeof(TDao));
- Assert.IsFalse(string.IsNullOrEmpty(attr.Schema), "Attribute Table has no Schema set");
- }
- protected void CheckColumnCode(int? alternativeLength)
- {
- if (alternativeLength == null)
- alternativeLength = 100;
- CheckColumnMappings("Code", string.Empty,true, alternativeLength);
- }
- protected void CheckColumnName(int? alternativeLength)
- {
- if (alternativeLength == null)
- alternativeLength = 200;
- CheckColumnMappings("Name", string.Empty,true, alternativeLength);
- }
- protected void CheckColumnDescription(int? alternativeLength)
- {
- if (alternativeLength == null)
- alternativeLength = 500;
- CheckColumnMappings("Description", string.Empty,false, alternativeLength);
- }
- protected void CheckColumnModuleCode(int? alternativeLength)
- {
- if (alternativeLength == null)
- alternativeLength = 10;
- CheckColumnMappings("ModuleCode", string.Empty,true, alternativeLength);
- }
- protected void CheckColumnEnabled(bool isRequired, bool defaultValue)
- {
- CheckColumnMappings("IsEnabled", string.Empty,isRequired,null, defaultValue);
- }
- }
- }
|