Migrate NPocoTests
This commit is contained in:
@@ -53,9 +53,9 @@ namespace Umbraco.Tests.Benchmarks
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var sql = Sql.BuilderFor(SqlContext)
|
||||
.Select<NPocoFetchTests.Thing1Dto>()
|
||||
.From<NPocoFetchTests.Thing1Dto>()
|
||||
.Where<NPocoFetchTests.Thing1Dto>(x => x.Name == "yada");
|
||||
.Select<Thing1Dto>()
|
||||
.From<Thing1Dto>()
|
||||
.Where<Thing1Dto>(x => x.Name == "yada");
|
||||
|
||||
var sqlString = sql.SQL; // force-build the SQL
|
||||
}
|
||||
@@ -69,9 +69,9 @@ namespace Umbraco.Tests.Benchmarks
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var template = SqlTemplates.Get("test", s => s
|
||||
.Select<NPocoFetchTests.Thing1Dto>()
|
||||
.From<NPocoFetchTests.Thing1Dto>()
|
||||
.Where<NPocoFetchTests.Thing1Dto>(x => x.Name == SqlTemplate.Arg<string>("name")));
|
||||
.Select<Thing1Dto>()
|
||||
.From<Thing1Dto>()
|
||||
.Where<Thing1Dto>(x => x.Name == SqlTemplate.Arg<string>("name")));
|
||||
|
||||
var sql = template.Sql(new { name = "yada" });
|
||||
|
||||
@@ -79,5 +79,17 @@ namespace Umbraco.Tests.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[TableName("zbThing1")]
|
||||
[PrimaryKey("id", AutoIncrement = false)]
|
||||
[ExplicitColumns]
|
||||
public class Thing1Dto
|
||||
{
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,35 +6,43 @@ using System.Text.RegularExpressions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Tests.Integration.Implementations;
|
||||
using Umbraco.Tests.Integration.Testing;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
// FIXME: npoco - is this still appropriate?
|
||||
//
|
||||
[TestFixture]
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
||||
public class NPocoBulkInsertTests : TestWithDatabaseBase
|
||||
public class NPocoBulkInsertTests : UmbracoIntegrationTest
|
||||
{
|
||||
private TestHelper _testHelper = new TestHelper();
|
||||
private IProfilingLogger ProfilingLogger => _testHelper.ProfilingLogger;
|
||||
|
||||
|
||||
[NUnit.Framework.Ignore("Ignored because you need to configure your own SQL Server to test thsi with")]
|
||||
[NUnit.Framework.Ignore("Ignored because you need to configure your own SQL Server to test this with")]
|
||||
[Test]
|
||||
public void Can_Bulk_Insert_Native_Sql_Server_Bulk_Inserts()
|
||||
{
|
||||
// create the db
|
||||
// prob not what we want, this is not a real database, but hey, the test is ignored anyways
|
||||
// we'll fix this when we have proper testing infrastructure
|
||||
var dbSqlServer = TestObjects.GetUmbracoSqlServerDatabase(new NullLogger<UmbracoDatabase>());
|
||||
// var dbSqlServer = TestObjects.GetUmbracoSqlServerDatabase(new NullLogger<UmbracoDatabase>());
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
// Still no what we want, but look above.
|
||||
var dbSqlServer = scope.Database;
|
||||
//drop the table
|
||||
dbSqlServer.Execute("DROP TABLE [umbracoServer]");
|
||||
|
||||
//drop the table
|
||||
dbSqlServer.Execute("DROP TABLE [umbracoServer]");
|
||||
|
||||
//re-create it
|
||||
dbSqlServer.Execute(@"CREATE TABLE [umbracoServer](
|
||||
//re-create it
|
||||
dbSqlServer.Execute(@"CREATE TABLE [umbracoServer](
|
||||
[id] [int] IDENTITY(1,1) NOT NULL,
|
||||
[address] [nvarchar](500) NOT NULL,
|
||||
[computerName] [nvarchar](255) NOT NULL,
|
||||
@@ -47,27 +55,28 @@ namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
[id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
)");
|
||||
var data = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
data.Add(new ServerRegistrationDto
|
||||
var data = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
ServerAddress = "address" + i,
|
||||
ServerIdentity = "computer" + i,
|
||||
DateRegistered = DateTime.Now,
|
||||
IsActive = true,
|
||||
DateAccessed = DateTime.Now
|
||||
});
|
||||
}
|
||||
data.Add(new ServerRegistrationDto
|
||||
{
|
||||
ServerAddress = "address" + i,
|
||||
ServerIdentity = "computer" + i,
|
||||
DateRegistered = DateTime.Now,
|
||||
IsActive = true,
|
||||
DateAccessed = DateTime.Now
|
||||
});
|
||||
}
|
||||
|
||||
using (var tr = dbSqlServer.GetTransaction())
|
||||
{
|
||||
dbSqlServer.BulkInsertRecords(data);
|
||||
tr.Complete();
|
||||
}
|
||||
using (var tr = dbSqlServer.GetTransaction())
|
||||
{
|
||||
dbSqlServer.BulkInsertRecords(data);
|
||||
tr.Complete();
|
||||
}
|
||||
|
||||
// Assert
|
||||
Assert.That(dbSqlServer.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoServer"), Is.EqualTo(1000));
|
||||
// Assert
|
||||
Assert.That(dbSqlServer.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoServer"), Is.EqualTo(1000));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -4,19 +4,18 @@ using System.Linq;
|
||||
using NPoco;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Integration.Testing;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
[TestFixture]
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, WithApplication = true)]
|
||||
public class NPocoFetchTests : TestWithDatabaseBase
|
||||
public class NPocoFetchTests : UmbracoIntegrationTest
|
||||
{
|
||||
protected override void Initialize()
|
||||
[SetUp]
|
||||
protected void SeedDatabase()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
InsertData(scope.Database);
|
||||
@@ -4,14 +4,23 @@ using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Integration.Testing;
|
||||
using Umbraco.Tests.Testing;
|
||||
using static Umbraco.Core.Persistence.SqlExtensionsStatics;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NPocoSqlExtensionsTests : BaseUsingSqlCeSyntax
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
||||
public class NPocoSqlExtensionsTests : UmbracoIntegrationTest
|
||||
{
|
||||
private ISqlContext SqlContext => GetRequiredService<ISqlContext>();
|
||||
|
||||
private Sql<ISqlContext> Sql()
|
||||
{
|
||||
return NPoco.Sql.BuilderFor(SqlContext);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhereTest()
|
||||
{
|
||||
@@ -4,11 +4,10 @@ using NPoco;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Persistance.SqlCe;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NPocoSqlTemplateTests
|
||||
@@ -1,18 +1,26 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using NPoco;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Integration.Testing;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.NPocoTests
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.NPocoTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NPocoSqlTests : BaseUsingSqlCeSyntax
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
||||
public class NPocoSqlTests : UmbracoIntegrationTest
|
||||
{
|
||||
//x =>
|
||||
private ISqlContext SqlContext => GetRequiredService<ISqlContext>();
|
||||
|
||||
private Sql<ISqlContext> Sql()
|
||||
{
|
||||
return NPoco.Sql.BuilderFor(SqlContext);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Where_Clause_With_Starts_With_Additional_Parameters()
|
||||
@@ -170,8 +170,6 @@
|
||||
<Compile Include="Testing\Objects\TestDataSource.cs" />
|
||||
<Compile Include="Issues\U9560.cs" />
|
||||
<Compile Include="Migrations\AdvancedMigrationTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoFetchTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoSqlTemplateTests.cs" />
|
||||
<Compile Include="Routing\ContentFinderByUrlAndTemplateTests.cs" />
|
||||
<Compile Include="Routing\ContentFinderByUrlTests.cs" />
|
||||
<Compile Include="Routing\ContentFinderByUrlWithDomainsTests.cs" />
|
||||
@@ -199,7 +197,6 @@
|
||||
<Compile Include="Testing\TestingTests\NUnitTests.cs" />
|
||||
<Compile Include="Persistence\LocksTests.cs" />
|
||||
<Compile Include="Migrations\PostMigrationTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoSqlExtensionsTests.cs" />
|
||||
<Compile Include="Testing\UmbracoTestBase.cs" />
|
||||
<Compile Include="TestHelpers\TestObjects-Mocks.cs" />
|
||||
<Compile Include="TestHelpers\TestObjects.cs" />
|
||||
@@ -238,7 +235,6 @@
|
||||
<Compile Include="Models\ContentExtensionsTests.cs" />
|
||||
<Compile Include="Web\Mvc\MergeParentContextViewDataAttributeTests.cs" />
|
||||
<Compile Include="Web\Mvc\ViewDataDictionaryExtensionTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoBulkInsertTests.cs" />
|
||||
<Compile Include="Persistence\Querying\ContentTypeSqlMappingTests.cs" />
|
||||
<Compile Include="PublishedContent\PublishedContentExtensionTests.cs" />
|
||||
<Compile Include="PublishedContent\PublishedRouterTests.cs" />
|
||||
@@ -273,7 +269,6 @@
|
||||
<Compile Include="Web\Mvc\HtmlHelperExtensionMethodsTests.cs" />
|
||||
<Compile Include="Persistence\SqlCeTableByTableTest.cs" />
|
||||
<Compile Include="Persistence\DatabaseContextTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoSqlTests.cs" />
|
||||
<Compile Include="Persistence\Querying\QueryBuilderTests.cs" />
|
||||
<Compile Include="PublishedContent\PublishedContentMoreTests.cs" />
|
||||
<Compile Include="Cache\PublishedCache\PublishedContentCacheTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user