forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceHostTestBase.cs
More file actions
57 lines (50 loc) · 978 Bytes
/
ServiceHostTestBase.cs
File metadata and controls
57 lines (50 loc) · 978 Bytes
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
using System;
using NUnit.Framework;
using ServiceStack.WebHost.Endpoints.Tests.Support.Host;
namespace ServiceStack.WebHost.Endpoints.Tests
{
public class ServiceHostTestBase
{
public static TestAppHost CreateAppHost()
{
var appHost = new TestAppHost();
appHost.Init();
return appHost;
}
public void ShouldThrow<T>(Action action)
where T : Exception
{
ShouldThrow<T>(action, "Should Throw");
}
public void ShouldThrow<T>(Action action, string errorMessageIfNotThrows)
where T : Exception
{
try
{
action();
}
catch (T)
{
return;
}
Assert.Fail(errorMessageIfNotThrows);
}
public void ShouldNotThrow<T>(Action action)
where T : Exception
{
ShouldNotThrow<T>(action, "Should not Throw");
}
public void ShouldNotThrow<T>(Action action, string errorMessageIfThrows)
where T : Exception
{
try
{
action();
}
catch (T)
{
Assert.Fail(errorMessageIfThrows);
}
}
}
}