Unit tests covering Mapper implementations for U4-978
This commit is contained in:
@@ -5,7 +5,7 @@ using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
internal abstract class BaseMapper
|
||||
public abstract class BaseMapper
|
||||
{
|
||||
internal abstract void BuildMap();
|
||||
|
||||
|
||||
@@ -37,15 +37,15 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
CacheMap<Content, NodeDto>(src => src.Trashed, dto => dto.Trashed);
|
||||
CacheMap<Content, NodeDto>(src => src.Key, dto => dto.UniqueId);
|
||||
CacheMap<Content, NodeDto>(src => src.UserId, dto => dto.UserId);
|
||||
//CacheMap<Content, DocumentDto>(src => src.Name, dto => dto.Alias);
|
||||
CacheMap<Content, ContentVersionDto>(src => src.UpdateDate, dto => dto.VersionDate);
|
||||
CacheMap<Content, ContentVersionDto>(src => src.Version, dto => dto.VersionId);
|
||||
CacheMap<Content, DocumentDto>(src => src.Name, dto => dto.Text);
|
||||
CacheMap<Content, DocumentDto>(src => src.ExpireDate, dto => dto.ExpiresDate);
|
||||
CacheMap<Content, DocumentDto>(src => src.ReleaseDate, dto => dto.ReleaseDate);
|
||||
CacheMap<Content, DocumentDto>(src => src.Published, dto => dto.Published);
|
||||
CacheMap<Content, DocumentDto>(src => src.UpdateDate, dto => dto.UpdateDate);
|
||||
//CacheMap<Content, DocumentDto>(src => src.Name, dto => dto.Alias);
|
||||
//CacheMap<Content, DocumentDto>(src => src, dto => dto.Newest);
|
||||
//CacheMap<Content, DocumentDto>(src => src.Template, dto => dto.TemplateId);
|
||||
CacheMap<Content, DocumentDto>(src => src.Name, dto => dto.Text);
|
||||
CacheMap<Content, DocumentDto>(src => src.Version, dto => dto.VersionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,13 +25,10 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
|
||||
internal override void BuildMap()
|
||||
{
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.Id, dto => dto.Id);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.Id, dto => dto.PrimaryKey);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.Key, dto => dto.Id);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.ItemKey, dto => dto.Key);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.ParentId, dto => dto.Parent);
|
||||
|
||||
CacheMap<DictionaryTranslation, LanguageTextDto>(src => src.Key, dto => dto.UniqueId);
|
||||
CacheMap<DictionaryTranslation, LanguageTextDto>(src => src.Language.Id, dto => dto.LanguageId);
|
||||
CacheMap<DictionaryTranslation, LanguageTextDto>(src => src.Value, dto => dto.Value);
|
||||
}
|
||||
|
||||
internal override string Map(string propertyName)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq.Expressions;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="DictionaryTranslation"/> to DTO mapper used to translate the properties of the public api
|
||||
/// implementation to that of the database's DTO as sql: [tableName].[columnName].
|
||||
/// </summary>
|
||||
public class DictionaryTranslationMapper : BaseMapper
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, DtoMapModel> PropertyInfoCache = new ConcurrentDictionary<string, DtoMapModel>();
|
||||
|
||||
internal static DictionaryTranslationMapper Instance = new DictionaryTranslationMapper();
|
||||
|
||||
private DictionaryTranslationMapper()
|
||||
{
|
||||
BuildMap();
|
||||
}
|
||||
|
||||
#region Overrides of BaseMapper
|
||||
|
||||
internal override void BuildMap()
|
||||
{
|
||||
CacheMap<DictionaryTranslation, LanguageTextDto>(src => src.Id, dto => dto.PrimaryKey);
|
||||
CacheMap<DictionaryTranslation, LanguageTextDto>(src => src.Key, dto => dto.UniqueId);
|
||||
CacheMap<DictionaryTranslation, LanguageTextDto>(src => src.Language, dto => dto.LanguageId);
|
||||
CacheMap<DictionaryTranslation, LanguageTextDto>(src => src.Value, dto => dto.Value);
|
||||
}
|
||||
|
||||
internal override string Map(string propertyName)
|
||||
{
|
||||
var dtoTypeProperty = PropertyInfoCache[propertyName];
|
||||
|
||||
return base.GetColumnName(dtoTypeProperty.Type, dtoTypeProperty.PropertyInfo);
|
||||
}
|
||||
|
||||
internal override void CacheMap<TSource, TDestination>(Expression<Func<TSource, object>> sourceMember, Expression<Func<TDestination, object>> destinationMember)
|
||||
{
|
||||
var property = base.ResolveMapping(sourceMember, destinationMember);
|
||||
PropertyInfoCache.AddOrUpdate(property.SourcePropertyName, property, (x, y) => property);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,8 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
CacheMap<Models.Media, NodeDto>(src => src.Trashed, dto => dto.Trashed);
|
||||
CacheMap<Models.Media, NodeDto>(src => src.Key, dto => dto.UniqueId);
|
||||
CacheMap<Models.Media, NodeDto>(src => src.UserId, dto => dto.UserId);
|
||||
CacheMap<Models.Media, ContentVersionDto>(src => src.UpdateDate, dto => dto.VersionDate);
|
||||
CacheMap<Models.Media, ContentVersionDto>(src => src.Version, dto => dto.VersionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,11 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
columnName = DictionaryMapper.Instance.Map(pi.Name);
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(DictionaryTranslation))
|
||||
{
|
||||
columnName = DictionaryTranslationMapper.Instance.Map(pi.Name);
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(Language))
|
||||
{
|
||||
columnName = LanguageMapper.Instance.Map(pi.Name);
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
CacheMap<Relation, RelationDto>(src => src.Comment, dto => dto.Comment);
|
||||
CacheMap<Relation, RelationDto>(src => src.CreateDate, dto => dto.Datetime);
|
||||
CacheMap<Relation, RelationDto>(src => src.ParentId, dto => dto.ParentId);
|
||||
CacheMap<Relation, RelationDto>(src => src.RelationType.Id, dto => dto.RelationType);
|
||||
CacheMap<Relation, RelationDto>(src => src.RelationType, dto => dto.RelationType);
|
||||
}
|
||||
|
||||
internal override string Map(string propertyName)
|
||||
|
||||
@@ -135,6 +135,7 @@
|
||||
<Compile Include="Persistence\Mappers\ContentTypeMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\DataTypeDefinitionMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\DictionaryMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\DictionaryTranslationMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\DtoMapModel.cs" />
|
||||
<Compile Include="Persistence\Mappers\LanguageMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\MediaMapper.cs" />
|
||||
|
||||
62
src/Umbraco.Tests/Persistence/Mappers/ContentMapperTest.cs
Normal file
62
src/Umbraco.Tests/Persistence/Mappers/ContentMapperTest.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Trashed_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentMapper.Instance.Map("Trashed");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[trashed]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Published_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentMapper.Instance.Map("Published");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsDocument].[published]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Version_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentMapper.Instance.Map("Version");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsContentVersion].[VersionId]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentTypeMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentTypeMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Name_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentTypeMapper.Instance.Map("Name");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[text]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Thumbnail_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentTypeMapper.Instance.Map("Thumbnail");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsContentType].[thumbnail]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Description_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = ContentTypeMapper.Instance.Map("Description");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsContentType].[description]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class DataTypeDefinitionMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DataTypeDefinitionMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Key_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DataTypeDefinitionMapper.Instance.Map("Key");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[uniqueID]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_DatabaseType_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DataTypeDefinitionMapper.Instance.Map("DatabaseType");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsDataType].[dbType]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_ControlId_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DataTypeDefinitionMapper.Instance.Map("ControlId");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsDataType].[controlId]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class DictionaryMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DictionaryMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsDictionary].[pk]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Key_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DictionaryMapper.Instance.Map("Key");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsDictionary].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_ItemKey_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DictionaryMapper.Instance.Map("ItemKey");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsDictionary].[key]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class DictionaryTranslationMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Key_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DictionaryTranslationMapper.Instance.Map("Key");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsLanguageText].[UniqueId]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Language_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DictionaryTranslationMapper.Instance.Map("Language");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsLanguageText].[languageId]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Value_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = DictionaryTranslationMapper.Instance.Map("Value");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsLanguageText].[value]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
49
src/Umbraco.Tests/Persistence/Mappers/LanguageMapperTest.cs
Normal file
49
src/Umbraco.Tests/Persistence/Mappers/LanguageMapperTest.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class LanguageMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = LanguageMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoLanguage].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_IsoCode_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = LanguageMapper.Instance.Map("IsoCode");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoLanguage].[languageISOCode]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_CultureName_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = LanguageMapper.Instance.Map("CultureName");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoLanguage].[languageCultureName]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
62
src/Umbraco.Tests/Persistence/Mappers/MediaMapperTest.cs
Normal file
62
src/Umbraco.Tests/Persistence/Mappers/MediaMapperTest.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class MediaMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = MediaMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Trashed_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = MediaMapper.Instance.Map("Trashed");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoNode].[trashed]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_UpdateDate_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = MediaMapper.Instance.Map("UpdateDate");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsContentVersion].[VersionDate]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Version_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = MediaMapper.Instance.Map("Version");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[cmsContentVersion].[VersionId]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
75
src/Umbraco.Tests/Persistence/Mappers/RelationMapperTest.cs
Normal file
75
src/Umbraco.Tests/Persistence/Mappers/RelationMapperTest.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class RelationMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelation].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_ChildId_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationMapper.Instance.Map("ChildId");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelation].[childId]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Datetime_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationMapper.Instance.Map("CreateDate");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelation].[datetime]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Comment_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationMapper.Instance.Map("Comment");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelation].[comment]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_RelationType_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationMapper.Instance.Map("RelationType");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelation].[relType]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Mappers
|
||||
{
|
||||
[TestFixture]
|
||||
public class RelationTypeMapperTest
|
||||
{
|
||||
[Test]
|
||||
public void Can_Map_Id_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationTypeMapper.Instance.Map("Id");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelationType].[id]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_Alias_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationTypeMapper.Instance.Map("Alias");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelationType].[alias]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_ChildObjectType_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationTypeMapper.Instance.Map("ChildObjectType");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelationType].[childObjectType]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Map_IsBidirectional_Property()
|
||||
{
|
||||
// Arrange
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
|
||||
// Act
|
||||
string column = RelationTypeMapper.Instance.Map("IsBidirectional");
|
||||
|
||||
// Assert
|
||||
Assert.That(column, Is.EqualTo("[umbracoRelationType].[dual]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,15 @@
|
||||
<Compile Include="Models\StylesheetTests.cs" />
|
||||
<Compile Include="Persistence\BaseTableByTableTest.cs" />
|
||||
<Compile Include="Persistence\DatabaseFactoryTests.cs" />
|
||||
<Compile Include="Persistence\Mappers\ContentMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\ContentTypeMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\DataTypeDefinitionMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\DictionaryMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\DictionaryTranslationMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\LanguageMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\MediaMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\RelationMapperTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\RelationTypeMapperTest.cs" />
|
||||
<Compile Include="Persistence\MySqlDatabaseCreationTest.cs" />
|
||||
<Compile Include="Persistence\MySqlTableByTableTest.cs" />
|
||||
<Compile Include="Persistence\RepositoryResolverTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user