forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerTests.cs
More file actions
78 lines (67 loc) · 2.44 KB
/
Copy pathContainerTests.cs
File metadata and controls
78 lines (67 loc) · 2.44 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
using System.Net.Http;
using System.Threading.Tasks;
using Funq;
using NUnit.Framework;
using ServiceStack;
namespace NetCoreTests
{
public class ContainerTests
{
class AppHost : AppSelfHostBase
{
public AppHost() : base(nameof(ContainerTests), typeof(ContainerTests).Assembly) { }
public override void Configure(Container container)
{
}
}
[Route("/haskeys")]
class HasQueryStringKeysTestDto {}
[Route("/numberofkeys")]
class NumberOfKeysTestDto {}
class HasKeysService : Service
{
public string Get(HasQueryStringKeysTestDto request)
{
return this.Request.QueryString.HasKeys().ToString();
}
public string Get(NumberOfKeysTestDto request)
{
return this.Request.QueryString.Count.ToString();
}
}
[Test]
public void Can_resolve_dependency_in_multiple_AppHosts()
{
using (var appHost = new AppHost().Init().Start("http://localhost:2000/"))
{
var logFactory = appHost.TryResolve<Microsoft.Extensions.Logging.ILoggerFactory>();
var log = logFactory.CreateLogger("categoryName");
}
using (var appHost = new AppHost().Init().Start("http://localhost:2000/"))
{
var logFactory = appHost.TryResolve<Microsoft.Extensions.Logging.ILoggerFactory>();
var log = logFactory.CreateLogger("categoryName");
}
}
[Test]
public async Task Can_use_haskeys()
{
using (var appHost = new AppHost().Init().Start("http://localhost:2000/"))
{
var client = new HttpClient();
var result = await client.GetStringAsync("http://localhost:2000/haskeys?test=foo");
Assert.That(result.ToLower(), Is.EqualTo("true"));
}
}
[Test]
public async Task Can_use_AllKeys()
{
using (var appHost = new AppHost().Init().Start("http://localhost:2000/"))
{
var client = new HttpClient();
var result = await client.GetStringAsync("http://localhost:2000/numberofkeys?test=foo");
Assert.That(result, Is.EqualTo("1"));
}
}
}
}