Skip to content

Commit

Permalink
fix broken tests to do with feature out refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Oct 4, 2012
1 parent 7283c24 commit aac7e73
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 42 deletions.
9 changes: 9 additions & 0 deletions src/ServiceStack/MetadataFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ private static IHttpHandler GetHandlerForPathParts(string[] pathParts)
}

var pathAction = string.Intern(pathParts[1].ToLower());
if (pathAction == "wsdl")
{
if (pathController == "soap11")
return new Soap11WsdlMetadataHandler();
if (pathController == "soap12")
return new Soap12WsdlMetadataHandler();
}

if (pathAction != "metadata") return null;

switch (pathController)
{
case "json":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using ServiceStack.WebHost.Endpoints.Metadata;

namespace ServiceStack.WebHost.Endpoints.Tests
{
[TestFixture]
public class ServiceStackHttpHandlerFactoryTests
{
readonly Dictionary<string, Type> pathInfoMap = new Dictionary<string, Type>
using System;
using System.Collections.Generic;
using System.Net;
using System.Web;
using NUnit.Framework;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints.Metadata;

namespace ServiceStack.WebHost.Endpoints.Tests
{
[TestFixture]
public class ServiceStackHttpHandlerFactoryTests
{
readonly Dictionary<string, Type> pathInfoMap = new Dictionary<string, Type>
{
{"Metadata", typeof(IndexMetadataHandler)},
{"Soap11", typeof(Soap11MessageSyncReplyHttpHandler)},
Expand All @@ -31,31 +34,44 @@ public class ServiceStackHttpHandlerFactoryTests

{"Soap12/Wsdl", typeof(Soap12WsdlMetadataHandler)},
{"Soap12/Metadata", typeof(Soap12MetadataHandler)},
};

[Test]
public void Resolves_the_right_handler_for_expexted_paths()
{
foreach (var item in pathInfoMap)
{
var expectedType = item.Value;
var handler = ServiceStackHttpHandlerFactory.GetHandlerForPathInfo(null, item.Key, null, null);
Assert.That(handler.GetType(), Is.EqualTo(expectedType));
}
}

[Test]
public void Resolves_the_right_handler_for_case_insensitive_expexted_paths()
{
foreach (var item in pathInfoMap)
{
var expectedType = item.Value;
var lowerPathInfo = item.Key.ToLower();
var handler = ServiceStackHttpHandlerFactory.GetHandlerForPathInfo(null, lowerPathInfo, null, null);
Assert.That(handler.GetType(), Is.EqualTo(expectedType));
}
}


}
};

[Test]
public void Resolves_the_right_handler_for_expexted_paths()
{
RegisterConfig();
foreach (var item in pathInfoMap)
{
var expectedType = item.Value;
var handler = ServiceStackHttpHandlerFactory.GetHandlerForPathInfo(null, item.Key, null, null);
Assert.That(handler.GetType(), Is.EqualTo(expectedType));
}
}

private void RegisterConfig()
{
EndpointHost.Config = new EndpointHostConfig("ServiceName", new ServiceManager(GetType().Assembly)) {
RawHttpHandlers = new List<Func<IHttpRequest,IHttpHandler>>(),
CustomHttpHandlers = new Dictionary<HttpStatusCode, IHttpHandler>(),
WebHostPhysicalPath = "~/".MapServerPath()
};
EndpointHost.CatchAllHandlers.Add(new PredefinedRoutesFeature().ProcessRequest);
EndpointHost.CatchAllHandlers.Add(new MetadataFeature().ProcessRequest);
}

[Test]
public void Resolves_the_right_handler_for_case_insensitive_expexted_paths()
{
RegisterConfig();
foreach (var item in pathInfoMap)
{
var expectedType = item.Value;
var lowerPathInfo = item.Key.ToLower();
var handler = ServiceStackHttpHandlerFactory.GetHandlerForPathInfo(null, lowerPathInfo, null, null);
Assert.That(handler.GetType(), Is.EqualTo(expectedType));
}
}


}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
using NUnit.Framework;
using ServiceStack.ServiceInterface.Testing;
using System;
using System.Collections.Generic;
using System.Net;
using System.Web;
using NUnit.Framework;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface.Testing;
using ServiceStack.WebHost.Endpoints;
using ServiceStack.WebHost.IntegrationTests.Services;

namespace ServiceStack.WebHost.IntegrationTests.Tests
Expand All @@ -18,8 +24,15 @@ protected override void Configure(Funq.Container container) { }
[SetUp]
public void OnBeforeTest()
{
base.OnBeforeEachTest();
}
base.OnBeforeEachTest();
RegisterConfig();
}

private void RegisterConfig()
{
EndpointHost.CatchAllHandlers.Add(new PredefinedRoutesFeature().ProcessRequest);
EndpointHost.CatchAllHandlers.Add(new MetadataFeature().ProcessRequest);
}

[Test]
public void Can_process_default_request()
Expand Down

0 comments on commit aac7e73

Please sign in to comment.