forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdapterFactoryTest.cs
More file actions
83 lines (70 loc) · 2.13 KB
/
AdapterFactoryTest.cs
File metadata and controls
83 lines (70 loc) · 2.13 KB
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
using Simple.Data.Operations;
namespace Simple.Data.UnitTest
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
[TestFixture]
public class AdapterFactoryTest
{
private static AdapterFactory CreateTarget()
{
return new CachingAdapterFactory(new StubComposer());
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void CreateWithAnonymousObjectWithoutConnectionStringThrowsArgumentException()
{
CreateTarget().Create(new { X = "" });
}
[Test]
public void CreateWithName()
{
var actual = CreateTarget().Create("Stub", null);
Assert.IsNotNull(actual);
}
}
class StubComposer : Composer
{
public override T Compose<T>()
{
return (T) Create();
}
public override T Compose<T>(string contractName)
{
return (T)Create();
}
private object Create()
{
return new StubAdapter();
}
}
class StubAdapter : Adapter
{
public override IEqualityComparer<string> KeyComparer
{
get { return StringComparer.OrdinalIgnoreCase; }
}
public override IReadOnlyDictionary<string, object> GetKey(string tableName, IReadOnlyDictionary<string, object> record)
{
throw new NotImplementedException();
}
public override IList<string> GetKeyNames(string tableName)
{
throw new NotImplementedException();
}
public override Task<OperationResult> Execute(IOperation operation)
{
throw new NotImplementedException();
}
public override bool IsExpressionFunction(string functionName, params object[] args)
{
throw new NotImplementedException();
}
public override IMetadata GetMetadata()
{
throw new NotImplementedException();
}
}
}