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 : DaoTest where TDao : Entity where TKey : IEquatable { 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.Has(typeof(TDao)), customMessage); var attr = AttributeQuery.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); } } }