forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestContextExtensionsTest.cs
More file actions
41 lines (34 loc) · 1.29 KB
/
Copy pathRequestContextExtensionsTest.cs
File metadata and controls
41 lines (34 loc) · 1.29 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
using NUnit.Framework;
using ServiceStack.CacheAccess.Providers;
using ServiceStack.Common.Web;
using ServiceStack.ServiceHost.Tests.Formats;
using ServiceStack.ServiceInterface.Testing;
using ServiceStack.WebHost.Endpoints;
using ServiceStack.WebHost.Endpoints.Formats;
namespace ServiceStack.ServiceHost.Tests
{
[TestFixture]
public class RequestContextExtensionsTest
{
[Test]
public void Can_optimize_result_with_ToOptimizedResult()
{
var dto = new TestDto {Name = "test"};
var httpReq = new MockHttpRequest();
httpReq.Headers.Add(HttpHeaders.AcceptEncoding, "gzip,deflate,sdch");
httpReq.ResponseContentType = "text/html";
var httpRes = new ViewTests.MockHttpResponse();
var httpRequestContext = new HttpRequestContext(httpReq, httpRes, dto);
var appHost = new TestAppHost();
new HtmlFormat().Register(appHost);
EndpointHost.ContentTypeFilter = appHost.ContentTypeFilters;
object result = httpRequestContext.ToOptimizedResult(dto);
Assert.IsNotNull(result);
Assert.IsTrue(result is CompressedResult);
}
public class TestDto
{
public string Name { get; set; }
}
}
}