blob: 4e0f618ccb783421514afd3434a4bdb870179e87 (
plain)
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
|
//-----------------------------------------------------------------------
// <copyright file="HostingTests.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.Hosting {
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using DotNetOpenAuth.Test.OpenId;
using NUnit.Framework;
[TestFixture, Category("HostASPNET")]
public class HostingTests : TestBase {
[TestCase]
public void AspHostBasicTest() {
try {
using (AspNetHost host = AspNetHost.CreateHost(TestWebDirectory)) {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host.BaseUri);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
using (StreamReader sr = new StreamReader(response.GetResponseStream())) {
string content = sr.ReadToEnd();
StringAssert.Contains("Test home page", content);
}
}
}
} catch (FileNotFoundException ex) {
Assert.Inconclusive(
"Unable to execute hosted ASP.NET tests because {0} could not be found. {1}", ex.FileName, ex.FusionLog);
} catch (WebException ex) {
if (ex.Response != null) {
using (var responseStream = new StreamReader(ex.Response.GetResponseStream())) {
Console.WriteLine(responseStream.ReadToEnd());
}
}
throw;
}
}
}
}
|