-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented proper, join-aware paging in SQL Server
- Loading branch information
1 parent
5bcbf2e
commit 54581ae
Showing
11 changed files
with
216 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,118 +1,118 @@ | |||
using System; | using System; | ||
using System.Collections.Generic; | using System.Collections.Generic; | ||
using System.Linq; | using System.Linq; | ||
using System.Text; | using System.Text; | ||
using NUnit.Framework; | using NUnit.Framework; | ||
using System.Data; | using System.Data; | ||
using Simple.Data.Ado.Schema; | using Simple.Data.Ado.Schema; | ||
using System.ComponentModel.Composition; | using System.ComponentModel.Composition; | ||
|
|
||
namespace Simple.Data.Ado.Test | namespace Simple.Data.Ado.Test | ||
{ | { | ||
[TestFixture] | [TestFixture] | ||
public class ProviderHelperTest | public class ProviderHelperTest | ||
{ | { | ||
[Test] | [Test] | ||
public void ShouldNotRequestExportableTypeFromServiceProvider() | public void ShouldNotRequestExportableTypeFromServiceProvider() | ||
{ | { | ||
var helper = new ProviderHelper(); | var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<ITestInterface>(connectionProvider); | var actual = helper.GetCustomProvider<ITestInterface>(connectionProvider); | ||
Assert.IsNull(connectionProvider.RequestedServiceType); | Assert.IsNull(connectionProvider.RequestedServiceType); | ||
} | } | ||
|
|
||
[Test] | [Test] | ||
public void ShouldRequestNonExportedTypeFromServiceProvider() | public void ShouldRequestNonExportedTypeFromServiceProvider() | ||
{ | { | ||
var helper = new ProviderHelper(); | var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | ||
Assert.AreEqual(typeof(IQueryPager), connectionProvider.RequestedServiceType); | Assert.AreEqual(typeof(IQueryPager), connectionProvider.RequestedServiceType); | ||
} | } | ||
|
|
||
[Test] | [Test] | ||
public void ShouldReturnNonExportedTypeFromServiceProvider() | public void ShouldReturnNonExportedTypeFromServiceProvider() | ||
{ | { | ||
var helper = new ProviderHelper(); | var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | ||
Assert.IsInstanceOf(typeof(IQueryPager), actual); | Assert.IsInstanceOf(typeof(IQueryPager), actual); | ||
} | } | ||
|
|
||
[Test] | [Test] | ||
public void ShouldFindProviderUsingAssemblyAttribute() | public void ShouldFindProviderUsingAssemblyAttribute() | ||
{ | { | ||
IConnectionProvider provider; | IConnectionProvider provider; | ||
Assert.True(ProviderHelper.TryLoadAssemblyUsingAttribute("Test", null, out provider)); | Assert.True(ProviderHelper.TryLoadAssemblyUsingAttribute("Test", null, out provider)); | ||
Assert.IsNotNull(provider); | Assert.IsNotNull(provider); | ||
Assert.IsInstanceOf<StubConnectionProvider>(provider); | Assert.IsInstanceOf<StubConnectionProvider>(provider); | ||
} | } | ||
|
|
||
public class StubConnectionAndServiceProvider : IConnectionProvider, IServiceProvider | public class StubConnectionAndServiceProvider : IConnectionProvider, IServiceProvider | ||
{ | { | ||
public void SetConnectionString(string connectionString) | public void SetConnectionString(string connectionString) | ||
{ | { | ||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||
} | } | ||
|
|
||
public IDbConnection CreateConnection() | public IDbConnection CreateConnection() | ||
{ | { | ||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||
} | } | ||
|
|
||
public ISchemaProvider GetSchemaProvider() | public ISchemaProvider GetSchemaProvider() | ||
{ | { | ||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||
} | } | ||
|
|
||
public string ConnectionString | public string ConnectionString | ||
{ | { | ||
get { throw new NotImplementedException(); } | get { throw new NotImplementedException(); } | ||
} | } | ||
|
|
||
public bool SupportsCompoundStatements | public bool SupportsCompoundStatements | ||
{ | { | ||
get { throw new NotImplementedException(); } | get { throw new NotImplementedException(); } | ||
} | } | ||
|
|
||
public string GetIdentityFunction() | public string GetIdentityFunction() | ||
{ | { | ||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||
} | } | ||
|
|
||
public bool SupportsStoredProcedures | public bool SupportsStoredProcedures | ||
{ | { | ||
get { throw new NotImplementedException(); } | get { throw new NotImplementedException(); } | ||
} | } | ||
|
|
||
public IProcedureExecutor GetProcedureExecutor(AdoAdapter adapter, ObjectName procedureName) | public IProcedureExecutor GetProcedureExecutor(AdoAdapter adapter, ObjectName procedureName) | ||
{ | { | ||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||
} | } | ||
|
|
||
public Type RequestedServiceType { get; private set; } | public Type RequestedServiceType { get; private set; } | ||
public Object GetService(Type serviceType) | public Object GetService(Type serviceType) | ||
{ | { | ||
this.RequestedServiceType = serviceType; | this.RequestedServiceType = serviceType; | ||
return new StubQueryPager(); | return new StubQueryPager(); | ||
} | } | ||
} | } | ||
|
|
||
public class StubQueryPager : IQueryPager | public class StubQueryPager : IQueryPager | ||
{ | { | ||
public IEnumerable<string> ApplyLimit(string sql, int take) | public IEnumerable<string> ApplyLimit(string sql, int take) | ||
{ | { | ||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||
} | } | ||
|
|
||
public IEnumerable<string> ApplyPaging(string sql, int skip, int take) | public IEnumerable<string> ApplyPaging(string sql, string[] keys, int skip, int take) | ||
{ | { | ||
throw new NotImplementedException(); | throw new NotImplementedException(); | ||
} | } | ||
} | } | ||
|
|
||
public interface ITestInterface { } | public interface ITestInterface { } | ||
[Export(typeof(ITestInterface))] | [Export(typeof(ITestInterface))] | ||
public class TestClass : ITestInterface { } | public class TestClass : ITestInterface { } | ||
} | } | ||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.