Simplify our Poco mappers

This commit is contained in:
Stephan
2019-03-29 08:30:51 +01:00
parent 07bb7ac0f7
commit 961cbf694e
58 changed files with 750 additions and 632 deletions

View File

@@ -1,9 +1,11 @@
using System;
using System.Collections.Concurrent;
using System.Linq.Expressions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using Moq;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.SqlSyntax;
@@ -13,9 +15,20 @@ namespace Umbraco.Tests.Benchmarks
[MemoryDiagnoser]
public class ModelToSqlExpressionHelperBenchmarks
{
protected ISqlContext MockSqlContext()
{
var sqlContext = Mock.Of<ISqlContext>();
var syntax = new SqlCeSyntaxProvider();
Mock.Get(sqlContext).Setup(x => x.SqlSyntax).Returns(syntax);
return sqlContext;
}
protected ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> CreateMaps()
=> new ConcurrentDictionary<Type, ConcurrentDictionary<string, string>>();
public ModelToSqlExpressionHelperBenchmarks()
{
var contentMapper = new ContentMapper();
var contentMapper = new ContentMapper(MockSqlContext(), CreateMaps());
_cachedExpression = new CachedExpression();
var mapperCollection = new Mock<IMapperCollection>();
mapperCollection.Setup(x => x[It.IsAny<Type>()]).Returns(contentMapper);