| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System.ComponentModel.DataAnnotations.Schema;
- using qdr.fnd.core.test;
- using Quadarax.Application.QLiberace.Common.Entities.Base;
- using Quadarax.Foundation.Core.Data.Entity;
- using Quadarax.Foundation.Core.Reflection;
- namespace Quadarax.Application.QLiberace.Base.Tests.Entities.Base
- {
- public abstract class BaseDaoTest<TDao,TKey> : DaoTest<TDao, TKey> where TDao : Entity<TKey>
- where TKey : IEquatable<TKey>
- {
- 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);
- }
- }
- }
|