|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using System.Text; |
5 | | -using NUnit.Framework; |
6 | | -using System.Data; |
7 | | -using Simple.Data.Ado.Schema; |
8 | | -using System.ComponentModel.Composition; |
9 | | - |
10 | | -namespace Simple.Data.Ado.Test |
11 | | -{ |
12 | | - [TestFixture] |
13 | | - public class ProviderHelperTest |
14 | | - { |
15 | | - [Test] |
16 | | - public void ShouldNotRequestExportableTypeFromServiceProvider() |
17 | | - { |
18 | | - var helper = new ProviderHelper(); |
19 | | - var connectionProvider = new StubConnectionAndServiceProvider(); |
20 | | - var actual = helper.GetCustomProvider<ITestInterface>(connectionProvider); |
21 | | - Assert.IsNull(connectionProvider.RequestedServiceType); |
22 | | - } |
23 | | - |
24 | | - [Test] |
25 | | - public void ShouldRequestNonExportedTypeFromServiceProvider() |
26 | | - { |
27 | | - var helper = new ProviderHelper(); |
28 | | - var connectionProvider = new StubConnectionAndServiceProvider(); |
29 | | - var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); |
30 | | - Assert.AreEqual(typeof(IQueryPager), connectionProvider.RequestedServiceType); |
31 | | - } |
32 | | - |
33 | | - [Test] |
34 | | - public void ShouldReturnNonExportedTypeFromServiceProvider() |
35 | | - { |
36 | | - var helper = new ProviderHelper(); |
37 | | - var connectionProvider = new StubConnectionAndServiceProvider(); |
38 | | - var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); |
39 | | - Assert.IsInstanceOf(typeof(IQueryPager), actual); |
40 | | - } |
41 | | - |
42 | | - [Test] |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using NUnit.Framework; |
| 6 | +using System.Data; |
| 7 | +using Simple.Data.Ado.Schema; |
| 8 | +using System.ComponentModel.Composition; |
| 9 | + |
| 10 | +namespace Simple.Data.Ado.Test |
| 11 | +{ |
| 12 | + [TestFixture] |
| 13 | + public class ProviderHelperTest |
| 14 | + { |
| 15 | + [Test] |
| 16 | + public void ShouldNotRequestExportableTypeFromServiceProvider() |
| 17 | + { |
| 18 | + var helper = new ProviderHelper(); |
| 19 | + var connectionProvider = new StubConnectionAndServiceProvider(); |
| 20 | + var actual = helper.GetCustomProvider<ITestInterface>(connectionProvider); |
| 21 | + Assert.IsNull(connectionProvider.RequestedServiceType); |
| 22 | + } |
| 23 | + |
| 24 | + [Test] |
| 25 | + public void ShouldRequestNonExportedTypeFromServiceProvider() |
| 26 | + { |
| 27 | + var helper = new ProviderHelper(); |
| 28 | + var connectionProvider = new StubConnectionAndServiceProvider(); |
| 29 | + var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); |
| 30 | + Assert.AreEqual(typeof(IQueryPager), connectionProvider.RequestedServiceType); |
| 31 | + } |
| 32 | + |
| 33 | + [Test] |
| 34 | + public void ShouldReturnNonExportedTypeFromServiceProvider() |
| 35 | + { |
| 36 | + var helper = new ProviderHelper(); |
| 37 | + var connectionProvider = new StubConnectionAndServiceProvider(); |
| 38 | + var actual = helper.GetCustomProvider<IQueryPager>(connectionProvider); |
| 39 | + Assert.IsInstanceOf(typeof(IQueryPager), actual); |
| 40 | + } |
| 41 | + |
| 42 | + [Test] |
43 | 43 | public void ShouldFindProviderUsingAssemblyAttribute() |
44 | 44 | { |
45 | 45 | IConnectionProvider provider; |
46 | 46 | Assert.True(ProviderHelper.TryLoadAssemblyUsingAttribute("Test", null, out provider)); |
47 | 47 | Assert.IsNotNull(provider); |
48 | 48 | Assert.IsInstanceOf<StubConnectionProvider>(provider); |
49 | | - } |
50 | | - |
51 | | - public class StubConnectionAndServiceProvider : IConnectionProvider, IServiceProvider |
52 | | - { |
53 | | - public void SetConnectionString(string connectionString) |
54 | | - { |
55 | | - throw new NotImplementedException(); |
56 | | - } |
57 | | - |
58 | | - public IDbConnection CreateConnection() |
59 | | - { |
60 | | - throw new NotImplementedException(); |
61 | | - } |
62 | | - |
63 | | - public ISchemaProvider GetSchemaProvider() |
64 | | - { |
65 | | - throw new NotImplementedException(); |
66 | | - } |
67 | | - |
68 | | - public string ConnectionString |
69 | | - { |
70 | | - get { throw new NotImplementedException(); } |
71 | | - } |
72 | | - |
73 | | - public bool SupportsCompoundStatements |
74 | | - { |
75 | | - get { throw new NotImplementedException(); } |
76 | | - } |
77 | | - |
78 | | - public string GetIdentityFunction() |
79 | | - { |
80 | | - throw new NotImplementedException(); |
81 | | - } |
82 | | - |
83 | | - public bool SupportsStoredProcedures |
84 | | - { |
85 | | - get { throw new NotImplementedException(); } |
86 | | - } |
87 | | - |
88 | | - public IProcedureExecutor GetProcedureExecutor(AdoAdapter adapter, ObjectName procedureName) |
89 | | - { |
90 | | - throw new NotImplementedException(); |
91 | | - } |
92 | | - |
93 | | - public Type RequestedServiceType { get; private set; } |
94 | | - public Object GetService(Type serviceType) |
95 | | - { |
96 | | - this.RequestedServiceType = serviceType; |
97 | | - return new StubQueryPager(); |
98 | | - } |
99 | | - } |
100 | | - |
101 | | - public class StubQueryPager : IQueryPager |
| 49 | + } |
| 50 | + |
| 51 | + public class StubConnectionAndServiceProvider : IConnectionProvider, IServiceProvider |
| 52 | + { |
| 53 | + public void SetConnectionString(string connectionString) |
| 54 | + { |
| 55 | + throw new NotImplementedException(); |
| 56 | + } |
| 57 | + |
| 58 | + public IDbConnection CreateConnection() |
| 59 | + { |
| 60 | + throw new NotImplementedException(); |
| 61 | + } |
| 62 | + |
| 63 | + public ISchemaProvider GetSchemaProvider() |
| 64 | + { |
| 65 | + throw new NotImplementedException(); |
| 66 | + } |
| 67 | + |
| 68 | + public string ConnectionString |
| 69 | + { |
| 70 | + get { throw new NotImplementedException(); } |
| 71 | + } |
| 72 | + |
| 73 | + public bool SupportsCompoundStatements |
| 74 | + { |
| 75 | + get { throw new NotImplementedException(); } |
| 76 | + } |
| 77 | + |
| 78 | + public string GetIdentityFunction() |
| 79 | + { |
| 80 | + throw new NotImplementedException(); |
| 81 | + } |
| 82 | + |
| 83 | + public bool SupportsStoredProcedures |
| 84 | + { |
| 85 | + get { throw new NotImplementedException(); } |
| 86 | + } |
| 87 | + |
| 88 | + public IProcedureExecutor GetProcedureExecutor(AdoAdapter adapter, ObjectName procedureName) |
| 89 | + { |
| 90 | + throw new NotImplementedException(); |
| 91 | + } |
| 92 | + |
| 93 | + public Type RequestedServiceType { get; private set; } |
| 94 | + public Object GetService(Type serviceType) |
| 95 | + { |
| 96 | + this.RequestedServiceType = serviceType; |
| 97 | + return new StubQueryPager(); |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + public class StubQueryPager : IQueryPager |
102 | 102 | { |
103 | 103 | public IEnumerable<string> ApplyLimit(string sql, int take) |
104 | 104 | { |
105 | 105 | throw new NotImplementedException(); |
106 | 106 | } |
107 | 107 |
|
108 | | - public IEnumerable<string> ApplyPaging(string sql, int skip, int take) |
109 | | - { |
110 | | - throw new NotImplementedException(); |
111 | | - } |
112 | | - } |
113 | | - |
114 | | - public interface ITestInterface { } |
115 | | - [Export(typeof(ITestInterface))] |
116 | | - public class TestClass : ITestInterface { } |
117 | | - } |
118 | | -} |
| 108 | + public IEnumerable<string> ApplyPaging(string sql, string[] keys, int skip, int take) |
| 109 | + { |
| 110 | + throw new NotImplementedException(); |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + public interface ITestInterface { } |
| 115 | + [Export(typeof(ITestInterface))] |
| 116 | + public class TestClass : ITestInterface { } |
| 117 | + } |
| 118 | +} |
0 commit comments