Permalink
Browse files

turn off validation for affected tests, convert tabs to spaces

  • Loading branch information...
1 parent 321a28e commit e14a6d1c600da1e3d594ea5474c22b8199e58801 @mythz mythz committed Mar 17, 2013
@@ -1,77 +1,85 @@
using System;
using NUnit.Framework;
using ServiceStack.ServiceHost.Tests.Support;
+using ServiceStack.WebHost.Endpoints;
namespace ServiceStack.ServiceHost.Tests
{
- [TestFixture]
- public class ServiceControllerTests
- {
- [Test]
- public void Can_register_all_services_in_an_assembly()
- {
- var serviceManager = new ServiceManager(typeof(BasicService).Assembly);
- serviceManager.Init();
+ [TestFixture]
+ public class ServiceControllerTests
+ {
+ [TestFixtureSetUp]
+ public void TestFixtureSetUp()
+ {
+ EndpointHostConfig.SkipRouteValidation = true;
+ }
+
+ [Test]
+ public void Can_register_all_services_in_an_assembly()
+ {
+ var serviceManager = new ServiceManager(typeof(BasicService).Assembly);
+ serviceManager.Init();
- var container = serviceManager.Container;
- container.Register<IFoo>(c => new Foo());
- container.Register<IBar>(c => new Bar());
+ var container = serviceManager.Container;
+ container.Register<IFoo>(c => new Foo());
+ container.Register<IBar>(c => new Bar());
- var serviceController = serviceManager.ServiceController;
+ var serviceController = serviceManager.ServiceController;
- var request = new AutoWire();
+ var request = new AutoWire();
- var response = serviceController.Execute(request) as AutoWireResponse;
+ var response = serviceController.Execute(request) as AutoWireResponse;
- Assert.That(response, Is.Not.Null);
- }
+ Assert.That(response, Is.Not.Null);
+ }
- [Test]
- public void Can_override_service_creation_with_custom_implementation()
- {
- var serviceManager = new ServiceManager(typeof(BasicService).Assembly);
- serviceManager.Init();
+ [Test]
+ public void Can_override_service_creation_with_custom_implementation()
+ {
+ var serviceManager = new ServiceManager(typeof(BasicService).Assembly);
+ serviceManager.Init();
- var container = serviceManager.Container;
- container.Register<IFoo>(c => new Foo());
- container.Register<IBar>(c => new Bar());
+ var container = serviceManager.Container;
+ container.Register<IFoo>(c => new Foo());
+ container.Register<IBar>(c => new Bar());
- var serviceController = serviceManager.ServiceController;
+ var serviceController = serviceManager.ServiceController;
- var request = new AutoWire();
+ var request = new AutoWire();
- var response = serviceController.Execute(request) as AutoWireResponse;
+ var response = serviceController.Execute(request) as AutoWireResponse;
- Assert.That(response, Is.Not.Null);
- Assert.That(response.Foo as Foo, Is.Not.Null);
- Assert.That(response.Bar as Bar, Is.Not.Null);
+ Assert.That(response, Is.Not.Null);
+ Assert.That(response.Foo as Foo, Is.Not.Null);
+ Assert.That(response.Bar as Bar, Is.Not.Null);
- container.Register(c =>
- new AutoWireService(new Foo2()) {
- Bar = new Bar2()
- });
+ container.Register(c =>
+ new AutoWireService(new Foo2())
+ {
+ Bar = new Bar2()
+ });
- response = serviceController.Execute(request) as AutoWireResponse;
+ response = serviceController.Execute(request) as AutoWireResponse;
- Assert.That(response, Is.Not.Null);
- Assert.That(response.Foo as Foo2, Is.Not.Null);
- Assert.That(response.Bar as Bar2, Is.Not.Null);
- }
+ Assert.That(response, Is.Not.Null);
+ Assert.That(response.Foo as Foo2, Is.Not.Null);
+ Assert.That(response.Bar as Bar2, Is.Not.Null);
+ }
- [Test]
- public void Can_inject_RequestContext_for_IRequiresRequestContext_services()
- {
- var serviceManager = new ServiceManager(typeof(RequiresContextService).Assembly);
- serviceManager.Init();
+ [Test]
+ public void Can_inject_RequestContext_for_IRequiresRequestContext_services()
+ {
+ var serviceManager = new ServiceManager(typeof(RequiresContextService).Assembly);
+ serviceManager.Init();
- var serviceController = serviceManager.ServiceController;
+ var serviceController = serviceManager.ServiceController;
- var request = new RequiresContext();
- var response = serviceController.Execute(request, new HttpRequestContext(request))
- as RequiresContextResponse;
+ var request = new RequiresContext();
+ var response = serviceController.Execute(request, new HttpRequestContext(request))
+ as RequiresContextResponse;
- Assert.That(response, Is.Not.Null);
- }
+ Assert.That(response, Is.Not.Null);
+ }
[Test]
public void Generic_Service_should_not_get_registered_with_generic_parameter()
@@ -152,13 +160,17 @@ public object Any(UsesQueryString request)
[Test]
public void Does_throw_on_invalid_Route_Definitions()
{
- var controller = new ServiceController(() => new[] {typeof (MyService)});
+ EndpointHostConfig.SkipRouteValidation = false;
+
+ var controller = new ServiceController(() => new[] { typeof(MyService) });
Assert.Throws<ArgumentException>(
() => controller.RegisterRestPaths(typeof(NoSlashPrefix)));
Assert.Throws<ArgumentException>(
() => controller.RegisterRestPaths(typeof(UsesQueryString)));
+
+ EndpointHostConfig.SkipRouteValidation = true;
}
- }
+ }
}
@@ -8,83 +8,85 @@
namespace ServiceStack.ServiceHost.Tests
{
- [Route("/notsingleton")]
- public class ServiceCreation
- {
- public bool RequestFilterExecuted { get; set; }
- public bool ContextualRequestFilterExecuted { get; set; }
- public bool RequestFilterDependenyIsResolved { get; set; }
- }
- public class ServiceCreationResponse
- {
- public int RequestCount { get; set; }
- }
+ [Route("/notsingleton")]
+ public class ServiceCreation
+ {
+ public bool RequestFilterExecuted { get; set; }
+ public bool ContextualRequestFilterExecuted { get; set; }
+ public bool RequestFilterDependenyIsResolved { get; set; }
+ }
+ public class ServiceCreationResponse
+ {
+ public int RequestCount { get; set; }
+ }
public class ServiceCreationService : ServiceInterface.Service
- {
- public int RequestCounter = 0;
-
- public object Any(ServiceCreation request)
- {
- this.RequestCounter++;
- return new ServiceCreationResponse()
- {
- RequestCount = this.RequestCounter
- };
- }
- }
-
- [TestFixture]
- public class ServiceCreationTest
- {
- private const string ListeningOn = "http://localhost:82/";
- private const string ServiceClientBaseUri = "http://localhost:82/";
-
- public class AttributeFiltersAppHostHttpListener
- : AppHostHttpListenerBase
- {
-
- public AttributeFiltersAppHostHttpListener()
- : base("Service Creation Tests", typeof(ServiceCreationService).Assembly) { }
-
- public override void Configure(Funq.Container container)
- {
- container.Register<ICacheClient>(new MemoryCacheClient());
- }
- }
-
- AttributeFiltersAppHostHttpListener appHost;
-
- [TestFixtureSetUp]
- public void OnTestFixtureSetUp()
- {
- appHost = new AttributeFiltersAppHostHttpListener();
- appHost.Init();
- appHost.Start(ListeningOn);
- }
-
- [TestFixtureTearDown]
- public void OnTestFixtureTearDown()
- {
- appHost.Dispose();
- }
-
- protected static IRestClient[] RestClients =
+ {
+ public int RequestCounter = 0;
+
+ public object Any(ServiceCreation request)
+ {
+ this.RequestCounter++;
+ return new ServiceCreationResponse()
+ {
+ RequestCount = this.RequestCounter
+ };
+ }
+ }
+
+ [TestFixture]
+ public class ServiceCreationTest
+ {
+ private const string ListeningOn = "http://localhost:82/";
+ private const string ServiceClientBaseUri = "http://localhost:82/";
+
+ public class AttributeFiltersAppHostHttpListener
+ : AppHostHttpListenerBase
+ {
+
+ public AttributeFiltersAppHostHttpListener()
+ : base("Service Creation Tests", typeof(ServiceCreationService).Assembly) { }
+
+ public override void Configure(Funq.Container container)
+ {
+ container.Register<ICacheClient>(new MemoryCacheClient());
+ }
+ }
+
+ AttributeFiltersAppHostHttpListener appHost;
+
+ [TestFixtureSetUp]
+ public void OnTestFixtureSetUp()
+ {
+ EndpointHostConfig.SkipRouteValidation = true;
+
+ appHost = new AttributeFiltersAppHostHttpListener();
+ appHost.Init();
+ appHost.Start(ListeningOn);
+ }
+
+ [TestFixtureTearDown]
+ public void OnTestFixtureTearDown()
+ {
+ appHost.Dispose();
+ }
+
+ protected static IRestClient[] RestClients =
{
new JsonServiceClient(ServiceClientBaseUri),
new XmlServiceClient(ServiceClientBaseUri),
new JsvServiceClient(ServiceClientBaseUri)
};
- [Test, TestCaseSource("RestClients")]
- public void Service_is_not_singleton(IRestClient client)
- {
- for (int i = 0; i < 5; i++)
- {
- var response = client.Post<ServiceCreationResponse>("notsingleton", new ServiceCreation() { });
- Assert.That(response.RequestCount, Is.EqualTo(1));
- }
- }
+ [Test, TestCaseSource("RestClients")]
+ public void Service_is_not_singleton(IRestClient client)
+ {
+ for (int i = 0; i < 5; i++)
+ {
+ var response = client.Post<ServiceCreationResponse>("notsingleton", new ServiceCreation() { });
+ Assert.That(response.RequestCount, Is.EqualTo(1));
+ }
+ }
public class Foo
{

0 comments on commit e14a6d1

Please sign in to comment.