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 | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,118 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using System.Data; | ||
using Simple.Data.Ado.Schema; | ||
using System.ComponentModel.Composition; | ||
|
||
namespace Simple.Data.Ado.Test | ||
{ | ||
[TestFixture] | ||
public class ProviderHelperTest | ||
{ | ||
[Test] | ||
public void ShouldNotRequestExportableTypeFromServiceProvider() | ||
{ | ||
var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<ITestInterface>(connectionProvider); | ||
Assert.IsNull(connectionProvider.RequestedServiceType); | ||
} | ||
|
||
[Test] | ||
public void ShouldRequestNonExportedTypeFromServiceProvider() | ||
{ | ||
var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | ||
Assert.AreEqual(typeof(IQueryPager), connectionProvider.RequestedServiceType); | ||
} | ||
|
||
[Test] | ||
public void ShouldReturnNonExportedTypeFromServiceProvider() | ||
{ | ||
var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | ||
Assert.IsInstanceOf(typeof(IQueryPager), actual); | ||
} | ||
|
||
[Test] | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using System.Data; | ||
using Simple.Data.Ado.Schema; | ||
using System.ComponentModel.Composition; | ||
|
||
namespace Simple.Data.Ado.Test | ||
{ | ||
[TestFixture] | ||
public class ProviderHelperTest | ||
{ | ||
[Test] | ||
public void ShouldNotRequestExportableTypeFromServiceProvider() | ||
{ | ||
var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<ITestInterface>(connectionProvider); | ||
Assert.IsNull(connectionProvider.RequestedServiceType); | ||
} | ||
|
||
[Test] | ||
public void ShouldRequestNonExportedTypeFromServiceProvider() | ||
{ | ||
var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | ||
Assert.AreEqual(typeof(IQueryPager), connectionProvider.RequestedServiceType); | ||
} | ||
|
||
[Test] | ||
public void ShouldReturnNonExportedTypeFromServiceProvider() | ||
{ | ||
var helper = new ProviderHelper(); | ||
var connectionProvider = new StubConnectionAndServiceProvider(); | ||
var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); | ||
Assert.IsInstanceOf(typeof(IQueryPager), actual); | ||
} | ||
|
||
[Test] | ||
public void ShouldFindProviderUsingAssemblyAttribute() | ||
{ | ||
IConnectionProvider provider; | ||
Assert.True(ProviderHelper.TryLoadAssemblyUsingAttribute("Test", null, out provider)); | ||
Assert.IsNotNull(provider); | ||
Assert.IsInstanceOf<StubConnectionProvider>(provider); | ||
} | ||
|
||
public class StubConnectionAndServiceProvider : IConnectionProvider, IServiceProvider | ||
{ | ||
public void SetConnectionString(string connectionString) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IDbConnection CreateConnection() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public ISchemaProvider GetSchemaProvider() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string ConnectionString | ||
{ | ||
get { throw new NotImplementedException(); } | ||
} | ||
|
||
public bool SupportsCompoundStatements | ||
{ | ||
get { throw new NotImplementedException(); } | ||
} | ||
|
||
public string GetIdentityFunction() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool SupportsStoredProcedures | ||
{ | ||
get { throw new NotImplementedException(); } | ||
} | ||
|
||
public IProcedureExecutor GetProcedureExecutor(AdoAdapter adapter, ObjectName procedureName) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Type RequestedServiceType { get; private set; } | ||
public Object GetService(Type serviceType) | ||
{ | ||
this.RequestedServiceType = serviceType; | ||
return new StubQueryPager(); | ||
} | ||
} | ||
|
||
public class StubQueryPager : IQueryPager | ||
} | ||
|
||
public class StubConnectionAndServiceProvider : IConnectionProvider, IServiceProvider | ||
{ | ||
public void SetConnectionString(string connectionString) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IDbConnection CreateConnection() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public ISchemaProvider GetSchemaProvider() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string ConnectionString | ||
{ | ||
get { throw new NotImplementedException(); } | ||
} | ||
|
||
public bool SupportsCompoundStatements | ||
{ | ||
get { throw new NotImplementedException(); } | ||
} | ||
|
||
public string GetIdentityFunction() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool SupportsStoredProcedures | ||
{ | ||
get { throw new NotImplementedException(); } | ||
} | ||
|
||
public IProcedureExecutor GetProcedureExecutor(AdoAdapter adapter, ObjectName procedureName) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Type RequestedServiceType { get; private set; } | ||
public Object GetService(Type serviceType) | ||
{ | ||
this.RequestedServiceType = serviceType; | ||
return new StubQueryPager(); | ||
} | ||
} | ||
|
||
public class StubQueryPager : IQueryPager | ||
{ | ||
public IEnumerable<string> ApplyLimit(string sql, int take) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IEnumerable<string> ApplyPaging(string sql, int skip, int take) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public interface ITestInterface { } | ||
[Export(typeof(ITestInterface))] | ||
public class TestClass : ITestInterface { } | ||
} | ||
} | ||
public IEnumerable<string> ApplyPaging(string sql, string[] keys, int skip, int take) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public interface ITestInterface { } | ||
[Export(typeof(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.