Migrate the bare minimum of BaseUsingSqlCeSyntax to be able to migrate NPoco unit tests
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using Moq;
|
||||
using NPoco;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
[TestFixture]
|
||||
public abstract class BaseUsingSqlSyntax
|
||||
{
|
||||
protected IMapperCollection Mappers { get; private set; }
|
||||
|
||||
protected ISqlContext SqlContext { get; private set; }
|
||||
|
||||
protected Sql<ISqlContext> Sql()
|
||||
{
|
||||
return NPoco.Sql.BuilderFor(SqlContext);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public virtual void Setup()
|
||||
{
|
||||
var container = TestHelper.GetRegister();
|
||||
var typeLoader = TestHelper.GetMockedTypeLoader();
|
||||
|
||||
var composition = new Composition(container, typeLoader, Mock.Of<IProfilingLogger>(), Mock.Of<IRuntimeState>(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
composition.WithCollectionBuilder<MapperCollectionBuilder>()
|
||||
.AddCoreMappers();
|
||||
|
||||
var factory = composition.CreateFactory();
|
||||
var pocoMappers = new NPoco.MapperCollection { new PocoMapper() };
|
||||
var pocoDataFactory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, pocoMappers).Init());
|
||||
var sqlSyntax = new SqlServerSyntaxProvider();
|
||||
SqlContext = new SqlContext(sqlSyntax, DatabaseType.SqlServer2012, pocoDataFactory, new Lazy<IMapperCollection>(() => factory.GetInstance<IMapperCollection>()));
|
||||
Mappers = factory.GetInstance<IMapperCollection>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,12 @@ using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using static Umbraco.Core.Persistence.SqlExtensionsStatics;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NPocoSqlExtensionsTests : BaseUsingSqlCeSyntax
|
||||
public class NPocoSqlExtensionsTests : BaseUsingSqlSyntax
|
||||
{
|
||||
[Test]
|
||||
public void WhereTest()
|
||||
@@ -6,6 +6,7 @@ using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
|
||||
@@ -9,10 +9,10 @@ using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NPocoSqlTests : BaseUsingSqlCeSyntax
|
||||
public class NPocoSqlTests : BaseUsingSqlSyntax
|
||||
{
|
||||
[Test]
|
||||
public void Where_Clause_With_Starts_With_Additional_Parameters()
|
||||
@@ -139,8 +139,6 @@
|
||||
<Compile Include="Migrations\MigrationPlanTests.cs" />
|
||||
<Compile Include="Migrations\MigrationTests.cs" />
|
||||
<Compile Include="Models\ContentXmlTest.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoSqlExtensionsTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoSqlTests.cs" />
|
||||
<Compile Include="PublishedContent\SolidPublishedSnapshot.cs" />
|
||||
<Compile Include="Published\ConvertersTests.cs" />
|
||||
<Compile Include="Published\ModelTypeTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user