Skip to content

Commit

Permalink
Merge pull request #914 from angelcolmenares/master
Browse files Browse the repository at this point in the history
Unit Tests: change port (82) to a registered port (1337), that can be used by ordinary users & use Environment.NewLine instead of \r\n
  • Loading branch information
mythz committed May 6, 2014
2 parents 103a11f + 1202e67 commit f3b9ef1
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void Register(IAppHost appHost)
public abstract class WebServicesTests
//: TestBase
{
public const string ListeningOn = "http://localhost:82/";
public const string ListeningOn = "http://localhost:1337/";
private const string TestString = "ServiceStack";

private ServiceStackHost appHost;
Expand Down Expand Up @@ -313,4 +313,4 @@ protected override IServiceClient CreateNewServiceClient()
return new Soap12ServiceClient(ListeningOn);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public object Any(AttributeFiltered request)
[TestFixture]
public class AttributeFiltersTest
{
private const string ListeningOn = "http://localhost:82/";
private const string ServiceClientBaseUri = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";
private const string ServiceClientBaseUri = "http://localhost:1337/";

public class AttributeFiltersAppHostHttpListener
: AppHostHttpListenerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ public void Can_download_CSV_Hello_using_csv_reply_endpoint()
var req = (HttpWebRequest)WebRequest.Create(ListeningOn + "csv/reply/Hello?Name=World!");

var res = req.GetResponse();
Assert.That(res.ContentType, Is.EqualTo(MimeTypes.Csv));
Assert.That(res.ContentType, Is.EqualTo(MimeTypes.Csv));
Assert.That(res.Headers[HttpHeaders.ContentDisposition], Is.EqualTo("attachment;filename=Hello.csv"));

var csv = res.ReadToEnd();
Assert.That(csv, Is.EqualTo("Result\r\n\"Hello, World!\"\r\n"));

var csv = res.ReadToEnd();
var lf = Environment.NewLine;
Assert.That(csv, Is.EqualTo("Result{0}\"Hello, World!\"{0}".Fmt(lf)));

Console.WriteLine(csv);
}
Expand All @@ -142,14 +143,15 @@ public void Can_download_CSV_Hello_using_csv_reply_endpoint()
public void Can_download_CSV_Hello_using_csv_Accept_and_RestPath()
{
var req = (HttpWebRequest)WebRequest.Create(ListeningOn + "hello/World!");
req.Accept = MimeTypes.Csv;
req.Accept = MimeTypes.Csv;

var res = req.GetResponse();
Assert.That(res.ContentType, Is.EqualTo(MimeTypes.Csv));
Assert.That(res.ContentType, Is.EqualTo(MimeTypes.Csv));
Assert.That(res.Headers[HttpHeaders.ContentDisposition], Is.EqualTo("attachment;filename=Hello.csv"));

var csv = res.ReadToEnd();
Assert.That(csv, Is.EqualTo("Result\r\n\"Hello, World!\"\r\n"));

var csv = res.ReadToEnd();
var lf = Environment.NewLine;
Assert.That(csv, Is.EqualTo("Result{0}\"Hello, World!\"{0}".Fmt(lf)));

Console.WriteLine(csv);
}
Expand All @@ -169,4 +171,4 @@ public void Can_download_CSV_movies_using_csv_reply_Path()
Assert.That(csvRows, Has.Count.EqualTo(HeaderRowCount + ResetMoviesService.Top5Movies.Count));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests
[TestFixture]
public class CustomRequestDataTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";

ExampleAppHostHttpListener appHost;
readonly JsonServiceClient client = new JsonServiceClient(ListeningOn);
Expand All @@ -41,7 +41,7 @@ public void OnTestFixtureTearDown()
[Test]
public void Can_parse_custom_form_data()
{
var webReq = (HttpWebRequest)WebRequest.Create("http://localhost:82/customformdata?format=json");
var webReq = (HttpWebRequest)WebRequest.Create("http://localhost:1337/customformdata?format=json");
webReq.Method = HttpMethods.Post;
webReq.ContentType = MimeTypes.FormUrlEncoded;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public object Delete(Customers request)
[TestFixture]
public class CustomerServiceValidationTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";

public class ValidationAppHostHttpListener
: AppHostHttpListenerBase
Expand Down Expand Up @@ -348,4 +348,4 @@ public void Post_ValidRequest_succeeds(Func<IServiceClient> factory)
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public object Any(ExceptionWithRequestBinding request)
[TestFixture]
public class ExceptionHandlingTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";

public class ExceptionHandlingAppHostHttpListener
: AppHostHttpListenerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests
[TestFixture]
public class HttpErrorAsyncTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";

ExampleAppHostHttpListener appHost;

Expand Down Expand Up @@ -115,4 +115,4 @@ public async Task PUT_returning_custom_403_Exception()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests
[TestFixture]
public class HttpErrorSyncTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";

private ExampleAppHostHttpListener appHost;

Expand Down Expand Up @@ -85,4 +85,4 @@ public void PUT_throwing_custom_403_Exception()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public object Any(PlainText request)
#endregion


private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";
SimpleAppHostHttpListener appHost;

public HttpResultContentTypeTests()
Expand Down Expand Up @@ -125,4 +125,4 @@ public void OnTestFixtureTearDown()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests.IntegrationTests
{
public class IntegrationTestBase
{
protected const string BaseUrl = "http://localhost:82/";
protected const string BaseUrl = "http://localhost:1337/";

private readonly IntegrationTestAppHost appHost;
public IntegrationTestBase()
Expand Down Expand Up @@ -108,4 +108,4 @@ public void DeleteOnEachEndpoint<TRes>(string relativePathOrAbsoluteUri, Action<
}
}
}
}
}
4 changes: 2 additions & 2 deletions tests/ServiceStack.WebHost.Endpoints.Tests/JsonpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests
{
public class JsonpTests
{
protected const string ListeningOn = "http://localhost:82/";
protected const string ListeningOn = "http://localhost:1337/";

ExampleAppHostHttpListener appHost;

Expand Down Expand Up @@ -56,4 +56,4 @@ public void Can_GET_single_Movie_using_RestClient_with_JSONP()
Assert.That(response.Length, Is.GreaterThan(50));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests
[TestFixture]
public class NestedServiceTests
{
protected const string ListeningOn = "http://localhost:82/";
protected const string ListeningOn = "http://localhost:1337/";

ExampleAppHostHttpListener appHost;

Expand Down Expand Up @@ -70,4 +70,4 @@ public object Any(Root.Nested request)
}
}

}
}
4 changes: 2 additions & 2 deletions tests/ServiceStack.WebHost.Endpoints.Tests/NewApiTodos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void DeleteByIds(params long[] ids)
[TestFixture]
public class NewApiTodosTests
{
const string BaseUri = "http://localhost:82/";
const string BaseUri = "http://localhost:1337/";

AppHost appHost;

Expand Down Expand Up @@ -140,4 +140,4 @@ public void Run()
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public object Any(ProtoBufEmail request)
[TestFixture]
public class ProtoBufServiceTests
{
protected const string ListeningOn = "http://localhost:85/";
protected const string ListeningOn = "http://localhost:1337/";

ExampleAppHostHttpListener appHost;

Expand Down Expand Up @@ -131,4 +131,4 @@ public void Can_Send_ProtoBuf_request()
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests
[TestFixture]
public class RemoteEndDropsConnectionTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";
ExampleAppHostHttpListener appHost;

public RemoteEndDropsConnectionTests()
Expand Down Expand Up @@ -127,4 +127,4 @@ public void TestClientDropsConnection(bool writeErrorsToResponse)
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ServiceStack.WebHost.Endpoints.Tests
[TestFixture]
public class RequestContextTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";

public class HeadersAppHostHttpListener
: AppHostHttpListenerBase
Expand Down Expand Up @@ -149,4 +149,4 @@ public void Does_return_bare_401_with_AuthRequired_header()


}
}
}
9 changes: 6 additions & 3 deletions tests/ServiceStack.WebHost.Endpoints.Tests/RouteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ public void Can_download_original_route_with_csv_extension()
httpRes.ContentType.Print();
Assert.That(httpRes.ContentType.MatchesContentType(MimeTypes.Csv));
});

Assert.That(response, Is.EqualTo("Data\r\nfoo\r\n"));

var lf = System.Environment.NewLine;
Assert.That(response, Is.EqualTo("Data{0}foo{0}".Fmt(lf)));
}
}

Expand Down Expand Up @@ -155,8 +156,10 @@ public void Can_download_modified_routes()

var response = Config.AbsoluteBaseUri.CombineWith("/api/modified/foo.csv")
.GetStringFromUrl();

var lf = System.Environment.NewLine;
Assert.That(response, Is.EqualTo("Data{0}foo{0}".Fmt(lf)));

Assert.That(response, Is.EqualTo("Data\r\nfoo\r\n"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public object Get(UserValidation request)
[TestFixture]
public class UserServiceValidationTests
{
private const string ListeningOn = "http://localhost:82/";
private const string ListeningOn = "http://localhost:1337/";

public class UserAppHostHttpListener
: AppHostHttpListenerBase
Expand Down

0 comments on commit f3b9ef1

Please sign in to comment.