Files
Umbraco-CMS/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs
Stephan 365a01a476 From PetaPoco to NPoco (#1207)
* NPoco - 2.x (builds)

* NPoco - v3.1 (does not build)

* NPoco - builds

* NPoco - configure database factory (tests fail)

* Pick fix from 7.4

* NPoco - stock v3.1 - sort-of working

* NPoco - fix merge

* Fix Newtonsoft.Json in web.Template.Debug.config

* NPoco - fix SELECT *

* NPoco - fixing repositories

* NPoco - fix EntityRepository

* NPoco - fix EntityRepository

* NPoco - cosmetic

* NPoco - use 3.1.0-u001 from github/zpqrtbnk/NPoco

* Fixes build, NPoco needed to be referenced in the cms and UmbracoExamine projects

* Fixes lots of tests

* fixes more tests

* NPoco - bugfixing

* Bugfix CacheHelper in tests

* Bugfix connection mocking in tests

* NPoco - inject database in Sql.Select<>

* NPoco - discovery retry policy only once

* Enable C# 6 for Umbraco.Core

* NPoco - introduce UmbracoSql, cleanup

* NPoco - more cleanup and fixing

* NPoco - fix UserRepository

* Optimize InGroupsOf

* Implement UmbracoDatabase.FetchByGroups

* NPoco - fix Select

* NPoco - simplify GetPagedResultsByQuery

* Cherry-pick DisableBrowserCacheAttribute fix from 7.4

* Upgrade NPoco to use Sql<TContext>

* U4-8257 - cleanup relators

* 4-8257 - cleanup more relators

* Upgrade NPoco with more OOTB version

* fixes a couple tests, changes double check lock to Lazy<T>
2016-04-12 15:11:07 +02:00

69 lines
2.2 KiB
C#

using LightInject;
using Moq;
using NPoco;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Profiling;
using Umbraco.Core.DependencyInjection;
using Umbraco.Core.Persistence;
namespace Umbraco.Tests.TestHelpers
{
[TestFixture]
public abstract class BaseUsingSqlCeSyntax
{
private MappingResolver _mappingResolver;
protected IMappingResolver MappingResolver => _mappingResolver;
protected SqlContext SqlContext { get; private set; }
protected Sql<SqlContext> Sql()
{
return NPoco.Sql.BuilderFor(SqlContext);
}
[SetUp]
public virtual void Initialize()
{
var sqlSyntax = new SqlCeSyntaxProvider();
var container = new ServiceContainer();
container.RegisterSingleton<ISqlSyntaxProvider>(factory => sqlSyntax);
container.RegisterSingleton<ILogger>(factory => Mock.Of<ILogger>());
container.RegisterSingleton<IProfiler>(factory => Mock.Of<IProfiler>());
_mappingResolver = new MappingResolver(container, Mock.Of<ILogger>(),
() => PluginManager.Current.ResolveAssignedMapperTypes());
var logger = new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>());
PluginManager.Current = new PluginManager(new ActivatorServiceProvider(), new NullCacheProvider(),
logger,
false);
var mappers = new MapperCollection { new PocoMapper() };
var pocoDataFactory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, mappers).Init());
SqlContext = new SqlContext(sqlSyntax, pocoDataFactory, DatabaseType.SQLCe);
Resolution.Freeze();
SetUp();
}
public virtual void SetUp()
{}
[TearDown]
public virtual void TearDown()
{
Resolution.Reset();
//MappingResolver.Reset();
PluginManager.Current = null;
}
}
}