Skip to content

Commit 8fd0b3f

Browse files
committed
Added option to configure the HttpConfiguration used in the testing (#139)
1 parent e52d869 commit 8fd0b3f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/MyWebApi/Builders/Controllers/ControllerBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private void PrepareController()
342342
{
343343
this.controller.Request = this.HttpRequestMessage;
344344
this.controller.RequestContext = this.HttpRequestMessage.GetRequestContext();
345-
this.controller.Configuration = new HttpConfiguration();
345+
this.controller.Configuration = MyWebApi.Configuration ?? new HttpConfiguration();
346346
this.controller.User = MockedIPrinciple.CreateUnauthenticated();
347347
}
348348

src/MyWebApi/MyWebApi.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ namespace MyWebApi
2727
/// </summary>
2828
public static class MyWebApi
2929
{
30+
public static void IsUsing(HttpConfiguration httpConfiguration)
31+
{
32+
Configuration = httpConfiguration;
33+
}
34+
3035
/// <summary>
3136
/// Selects controller on which the test will be executed. Controller is instantiated with default constructor.
3237
/// </summary>
@@ -63,5 +68,7 @@ public static IControllerBuilder<TController> Controller<TController>(Func<TCont
6368
var controllerInstance = construction();
6469
return new ControllerBuilder<TController>(controllerInstance);
6570
}
71+
72+
internal static HttpConfiguration Configuration { get; private set; }
6673
}
6774
}

0 commit comments

Comments
 (0)