Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/aspnetwebstack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/System.Web.Http.Integration.Test/PartialTrust/BasicScenarioTest.cs')
-rw-r--r--test/System.Web.Http.Integration.Test/PartialTrust/BasicScenarioTest.cs62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/System.Web.Http.Integration.Test/PartialTrust/BasicScenarioTest.cs b/test/System.Web.Http.Integration.Test/PartialTrust/BasicScenarioTest.cs
new file mode 100644
index 00000000..99d6d1e0
--- /dev/null
+++ b/test/System.Web.Http.Integration.Test/PartialTrust/BasicScenarioTest.cs
@@ -0,0 +1,62 @@
+using System.Net.Http;
+using System.Net.Http.Headers;
+using Xunit;
+using Xunit.Extensions;
+
+namespace System.Web.Http.PartialTrust
+{
+ public class BasicScenarioTest : MarshalByRefObject
+ {
+ [Fact]
+ public void BasicSelfHostedEchoControllerWorks()
+ {
+ ScenarioHelper.RunTest(
+ "Echo",
+ "/{s}",
+ new HttpRequestMessage(HttpMethod.Get, "http://localhost/Echo/foo"),
+ (response) =>
+ {
+ Assert.DoesNotThrow(() => response.EnsureSuccessStatusCode());
+ Assert.Equal("foo", response.Content.ReadAsStringAsync().Result);
+ }
+ );
+ }
+
+ [Theory]
+ [InlineData("application/json")]
+ [InlineData("text/xml")]
+ public void SimpleConNegWorks(string mediaType)
+ {
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Echo/ContentNegotiatedEcho/foo");
+ request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(mediaType));
+
+ ScenarioHelper.RunTest(
+ "Echo",
+ "/{action}/{s}",
+ request,
+ (response) =>
+ {
+ Assert.DoesNotThrow(() => response.EnsureSuccessStatusCode());
+ Assert.Equal(mediaType, response.Content.Headers.ContentType.MediaType);
+ }
+ );
+ }
+ }
+
+ [RunWith(typeof(PartialTrustRunner))]
+ public class PartialTrustBasicScenarioTest : BasicScenarioTest { }
+
+ public class EchoController : ApiController
+ {
+ public HttpResponseMessage Get(string s)
+ {
+ return new HttpResponseMessage() { Content = new StringContent(s) };
+ }
+
+ public string ContentNegotiatedEcho(string s)
+ {
+ return s;
+ }
+ }
+
+}