-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUnitTest1.cs
More file actions
68 lines (55 loc) · 2.04 KB
/
UnitTest1.cs
File metadata and controls
68 lines (55 loc) · 2.04 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
using System;
using ConnectionFactory;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Data.Common;
using System.Dynamic;
namespace ConnectionFactoryTest
{
[TestClass]
public class UnitTest1
{
protected static readonly bool IsAppVeyor = Environment.GetEnvironmentVariable("Appveyor")?.ToUpperInvariant() == "TRUE";
protected static string ConnName => IsAppVeyor ? "AppVeyor" : "teste";
[TestMethod]
public void TestCommandWithDynamicParameters()
{
string returnValue = null;
using (var conn = new CfConnection(ConnName))
{
var cmd = conn.CreateCfCommand();
DbDataReader result = (DbDataReader)cmd.ExecuteReader(CfCommandType.Text,
@"select *
from(select 'user1' as login) as t
where login = 'user1'",
new { login = "user1" });
if (result.Read())
{
returnValue = result["login"].ToString();
}
}
Assert.AreEqual(returnValue, "user1");
}
[TestMethod]
public void TestCommandWithExpandoObjectParameters()
{
string returnValue = null;
using (var conn = new CfConnection(ConnName))
{
var cmd = conn.CreateCfCommand();
var paramters = new ExpandoObject() as IDictionary<string, object>;
paramters.Add("login", "andersonn");
DbDataReader result = (DbDataReader)cmd.ExecuteReader(CfCommandType.Text,
@"select *
from(select 'user1' as login) as t
where login = 'user1'",
paramters);
if (result.Read())
{
returnValue = result["login"].ToString();
}
}
Assert.AreEqual(returnValue, "user1");
}
}
}