forked from ServiceStack/ServiceStack.Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetUsersTests.cs
More file actions
44 lines (38 loc) · 1.22 KB
/
GetUsersTests.cs
File metadata and controls
44 lines (38 loc) · 1.22 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
using NUnit.Framework;
using ServiceStack.Examples.ServiceInterface;
using ServiceStack.Examples.ServiceModel.Operations;
using ServiceStack.Examples.ServiceModel.Types;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.ServiceInterface.ServiceModel;
namespace ServiceStack.Examples.Tests
{
[TestFixture]
public class GetUsersTests
: TestHostBase
{
[Test]
public void GetUsers_Test()
{
var request = new GetUsers
{
UserIds = new ArrayOfLong(1, 2),
UserNames = new ArrayOfString("User3", "User4")
};
var factory = new OrmLiteConnectionFactory(
InMemoryDb, false, SqliteOrmLiteDialectProvider.Instance);
using (var dbConn = factory.OpenDbConnection())
using (var dbCmd = dbConn.CreateCommand())
{
dbCmd.CreateTable<User>(true);
dbCmd.Insert(new User { Id = 1, UserName = "User1" });
dbCmd.Insert(new User { Id = 2, UserName = "User2" });
dbCmd.Insert(new User { Id = 3, UserName = "User3" });
dbCmd.Insert(new User { Id = 4, UserName = "User4" });
var handler = new GetUsersService { ConnectionFactory = factory };
var response = (GetUsersResponse)handler.Execute(request);
Assert.That(response.Users.Count, Is.EqualTo(4));
}
}
}
}