Adding numeric attribute for testing.
Adding type test for composition implementation.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Umbraco.Tests.CodeFirst.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Interface, AllowMultiple = false, Inherited = true)]
|
||||
public class AliasAttribute : Attribute
|
||||
{
|
||||
public AliasAttribute(string @alias)
|
||||
|
||||
40
src/Umbraco.Tests/CodeFirst/Attributes/Numeric.cs
Normal file
40
src/Umbraco.Tests/CodeFirst/Attributes/Numeric.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.CodeFirst.Definitions;
|
||||
using umbraco.editorControls.numberfield;
|
||||
|
||||
namespace Umbraco.Tests.CodeFirst.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
public class Numeric : PropertyTypeAttribute
|
||||
{
|
||||
public Numeric(string dataTypeName)
|
||||
: base(typeof(IDataTypenteger))
|
||||
{
|
||||
DataTypeName = dataTypeName;
|
||||
DatabaseType = DataTypeDatabaseType.Integer;
|
||||
}
|
||||
|
||||
public string DataTypeName { get; set; }
|
||||
|
||||
public string PreValue { get; set; }
|
||||
|
||||
public override PropertyDefinition GetPropertyConvention()
|
||||
{
|
||||
var definition = new PropertyDefinition();
|
||||
|
||||
definition.Mandatory = Mandatory;
|
||||
definition.ValidationRegExp = string.IsNullOrEmpty(ValidationRegExp) ? ValidationRegExp : string.Empty;
|
||||
definition.PropertyGroup = string.IsNullOrEmpty(PropertyGroup) ? "Generic Properties" : PropertyGroup;
|
||||
definition.DataTypeDefinition = Conventions.CreateDataTypeDefinitionFromAttribute(this, DataTypeName);
|
||||
|
||||
if(string.IsNullOrEmpty(PreValue) == false)
|
||||
{
|
||||
Conventions.CreatePrevalueForDataTypeDefinition(definition.DataTypeDefinition.Id, PreValue, 0,
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
return definition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace Umbraco.Tests.CodeFirst.Attributes
|
||||
definition.Mandatory = Mandatory;
|
||||
definition.ValidationRegExp = string.IsNullOrEmpty(ValidationRegExp) ? ValidationRegExp : string.Empty;
|
||||
definition.PropertyGroup = string.IsNullOrEmpty(PropertyGroup) ? "Generic Properties" : PropertyGroup;
|
||||
definition.DataTypeDefinition = Conventions.DataTypeConvention(this, Type);
|
||||
definition.DataTypeDefinition = Conventions.GetDataTypeDefinitionByAttributeOrType(this, Type);
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user