Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
104 lines (90 loc) · 3.28 KB

File metadata and controls

104 lines (90 loc) · 3.28 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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);
}
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> ApplyPaging(string sql, int skip, int take)
{
throw new NotImplementedException();
}
}
public interface ITestInterface { }
[Export(typeof(ITestInterface))]
public class TestClass : ITestInterface { }
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.