Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed broken tests

  • Loading branch information...
commit a04594c88582c8527242f98fe48d5158dfa3e792 1 parent 77f68a4
Andreas Håkansson authored
8 src/Nancy.Embedded.Tests/Unit/EmbeddedStaticContentConventionBuilderFixture.cs
View
@@ -6,6 +6,8 @@
using System.Reflection;
using System.Text;
using Conventions;
+
+ using Nancy.Diagnostics;
using Nancy.Tests;
using Responses;
using Xunit;
@@ -64,7 +66,11 @@ private static string GetEmbeddedStaticContent(string virtualDirectory, string r
var context =
new NancyContext
{
- Request = new Request("GET", resource, "http")
+ Request = new Request("GET", resource, "http"),
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
};
var assembly =
24 src/Nancy.Testing/ConfigurableBootstrapper.cs
View
@@ -944,6 +944,30 @@ public ConfigurableBootstrapperConfigurator RenderContextFactory(IRenderContextF
}
/// <summary>
+ /// Configures the bootstrapper to use the provided instance of <see cref="IRequestTraceFactory"/>.
+ /// </summary>
+ /// <param name="requestTraceFactory">The <see cref="IRequestTraceFactory"/> instance that should be used by the bootstrapper.</param>
+ /// <returns>A reference to the current <see cref="ConfigurableBootstrapperConfigurator"/>.</returns>
+ public ConfigurableBootstrapperConfigurator RequestTraceFactory(IRequestTraceFactory requestTraceFactory)
+ {
+ this.bootstrapper.registeredInstances.Add(
+ new InstanceRegistration(typeof(IRequestTraceFactory), requestTraceFactory));
+
+ return this;
+ }
+
+ /// <summary>
+ /// Configures the bootstrapper to create an <see cref="IRequestTraceFactory"/> instance of the specified type.
+ /// </summary>
+ /// <typeparam name="T">The type of the <see cref="IRequestTraceFactory"/> that the bootstrapper should use.</typeparam>
+ /// <returns>A reference to the current <see cref="ConfigurableBootstrapperConfigurator"/>.</returns>
+ public ConfigurableBootstrapperConfigurator RequestTraceFactory<T>() where T : IRequestTraceFactory
+ {
+ this.bootstrapper.configuration.RequestTraceFactory = typeof(T);
+ return this;
+ }
+
+ /// <summary>
/// Configures the bootstrapper to use the provided instance of <see cref="IResponseFormatterFactory"/>.
/// </summary>
/// <param name="responseFormatterFactory">The <see cref="IResponseFormatterFactory"/> instance that should be used by the bootstrapper.</param>
1  src/Nancy.Testing/Nancy.Testing.csproj
View
@@ -117,6 +117,7 @@
<Compile Include="BrowserResponseBodyWrapper.cs" />
<Compile Include="BrowserResponseBodyWrapperExtensions.cs" />
<Compile Include="BrowserResponseExtensions.cs" />
+ <Compile Include="StaticConfigurationContext.cs" />
<Compile Include="TestingViewBrowserResponseExtensions.cs" />
<Compile Include="TestingViewFactory.cs" />
<Compile Include="ConfigurableBootstrapper.cs" />
49 src/Nancy.Tests/Unit/Diagnostics/DefaultRequestTraceFactoryFixture.cs
View
@@ -1,13 +1,10 @@
namespace Nancy.Tests.Unit.Diagnostics
{
- using System;
using System.Collections.Generic;
using System.IO;
-
- using FakeItEasy;
-
using Nancy.Diagnostics;
using Nancy.IO;
+ using Nancy.Testing;
using Xunit;
@@ -127,48 +124,4 @@ private static Request CreateRequest()
});
}
}
-
- public class StaticConfigurationContext : IDisposable
- {
- private readonly StaticConfigurationValues existingConfiguration = new StaticConfigurationValues();
-
- public StaticConfigurationContext(Action<StaticConfigurationValues> closure)
- {
- this.existingConfiguration.CaseSensitive = StaticConfiguration.CaseSensitive;
- this.existingConfiguration.DisableErrorTraces = StaticConfiguration.DisableErrorTraces;
- this.existingConfiguration.DisableMethodNotAllowedResponses = StaticConfiguration.DisableMethodNotAllowedResponses;
- this.existingConfiguration.RequestQueryFormMultipartLimit = StaticConfiguration.RequestQueryFormMultipartLimit;
-
- var temporaryConfiguration =
- new StaticConfigurationValues();
-
- closure.Invoke(temporaryConfiguration);
-
- AssignStaticConfigurationValues(temporaryConfiguration);
- }
-
- public void Dispose()
- {
- AssignStaticConfigurationValues(this.existingConfiguration);
- }
-
- private static void AssignStaticConfigurationValues(StaticConfigurationValues values)
- {
- StaticConfiguration.CaseSensitive = values.CaseSensitive;
- StaticConfiguration.DisableErrorTraces = values.DisableErrorTraces;
- StaticConfiguration.DisableMethodNotAllowedResponses = values.DisableMethodNotAllowedResponses;
- StaticConfiguration.RequestQueryFormMultipartLimit = values.RequestQueryFormMultipartLimit;
- }
-
- public class StaticConfigurationValues
- {
- public bool CaseSensitive { get; set; }
-
- public bool DisableErrorTraces { get; set; }
-
- public bool DisableMethodNotAllowedResponses { get; set; }
-
- public int RequestQueryFormMultipartLimit { get; set; }
- }
- }
}
48 src/Nancy.Tests/Unit/Routing/DefaultRouteInvokerFixture.cs
View
@@ -29,7 +29,13 @@ public void Should_invoke_route_with_provided_parameters()
// Given
var parameters = new DynamicDictionary();
var route = new FakeRoute(10);
- var context = new NancyContext();
+ var context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ };
// When
this.invoker.Invoke(route, new CancellationToken(), parameters, context);
@@ -44,7 +50,13 @@ public void Should_return_response_when_route_returns_int()
// Given
var parameters = new DynamicDictionary();
var route = new FakeRoute(10);
- var context = new NancyContext();
+ var context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ };
// When
var result = this.invoker.Invoke(route, new CancellationToken(), parameters, context).Result;
@@ -59,7 +71,13 @@ public void Should_return_response_when_route_returns_string()
// Given
var parameters = new DynamicDictionary();
var route = new FakeRoute("Hello World");
- var context = new NancyContext();
+ var context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ };
// When
var result = this.invoker.Invoke(route, new CancellationToken(), parameters, context).Result;
@@ -74,7 +92,13 @@ public void Should_return_response_when_route_returns_status_code()
// Given
var parameters = new DynamicDictionary();
var route = new FakeRoute(HttpStatusCode.OK);
- var context = new NancyContext();
+ var context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ };
// When
var result = this.invoker.Invoke(route, new CancellationToken(), parameters, context).Result;
@@ -90,7 +114,13 @@ public void Should_return_response_when_route_returns_action()
Action<Stream> action = s => { };
var parameters = new DynamicDictionary();
var route = new FakeRoute(action);
- var context = new NancyContext();
+ var context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ };
// When
var result = this.invoker.Invoke(route, new CancellationToken(), parameters, context).Result;
@@ -106,7 +136,13 @@ public void Should_handle_RouteExecutionEarlyExitException_gracefully()
var response = new Response();
var route = new FakeRoute((c, t) => { throw new RouteExecutionEarlyExitException(response); });
var parameters = new DynamicDictionary();
- var context = new NancyContext();
+ var context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ };
// When
var result = this.invoker.Invoke(route, new CancellationToken(), parameters, context).Result;
11 src/Nancy.Tests/Unit/StaticContentConventionBuilderFixture.cs
View
@@ -6,6 +6,7 @@
using System.IO;
using System.Text;
using Nancy.Conventions;
+ using Nancy.Diagnostics;
using Nancy.IO;
using Nancy.Responses;
using Xunit;
@@ -287,7 +288,15 @@ private static NancyContext GetContext(string virtualDirectory, string requested
new Url { Path = resource, Scheme = "http" },
headers: headers ?? new Dictionary<string, IEnumerable<string>>());
- var context = new NancyContext { Request = request };
+ var context = new NancyContext
+ {
+ Request = request,
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ };
+
return context;
}
18 src/Nancy.Tests/Unit/ViewEngines/DefaultViewFactoryFixture.cs
View
@@ -4,6 +4,8 @@ namespace Nancy.Tests.Unit.ViewEngines
using System.Dynamic;
using System.IO;
using FakeItEasy;
+
+ using Nancy.Diagnostics;
using Nancy.ViewEngines;
using Nancy.Tests.Fakes;
using Xunit;
@@ -31,7 +33,13 @@ public DefaultViewFactoryFixture()
this.viewLocationContext =
new ViewLocationContext
{
- Context = new NancyContext()
+ Context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ }
};
}
@@ -190,7 +198,13 @@ public void Should_retrieve_view_from_view_locator_using_provided_module_path()
var viewContext =
new ViewLocationContext
{
- Context = new NancyContext(),
+ Context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ },
ModulePath = "/bar"
};
9 src/Nancy.Tests/Unit/ViewEngines/DefaultViewResolverFixture.cs
View
@@ -6,6 +6,7 @@
using FakeItEasy;
using Nancy.Conventions;
+ using Nancy.Diagnostics;
using Nancy.ViewEngines;
using Xunit;
@@ -23,7 +24,13 @@ public DefaultViewResolverFixture()
this.viewLocationContext =
new ViewLocationContext
{
- Context = new NancyContext()
+ Context = new NancyContext
+ {
+ Trace = new DefaultRequestTrace
+ {
+ TraceLog = new DefaultTraceLog()
+ }
+ }
};
}
2  src/Nancy/Nancy.csproj
View
@@ -144,6 +144,7 @@
<Compile Include="DefaultResponseFormatterFactory.cs" />
<Compile Include="DefaultStaticContentProvider.cs" />
<Compile Include="Diagnostics\DefaultRequestTraceFactory.cs" />
+ <Compile Include="Diagnostics\DefaultTraceLog.cs" />
<Compile Include="Diagnostics\DiagnosticsConfiguration.cs" />
<Compile Include="Diagnostics\DiagnosticsSession.cs" />
<Compile Include="Diagnostics\ConcurrentLimitedCollection.cs" />
@@ -280,7 +281,6 @@
<Compile Include="Diagnostics\RequestTraceSession.cs" />
<Compile Include="Diagnostics\IRequestTracing.cs" />
<Compile Include="Diagnostics\DefaultRequestTrace.cs" />
- <Compile Include="Diagnostics\TraceLog.cs" />
<Compile Include="DynamicDictionaryValue.cs" />
<Compile Include="ErrorHandling\DefaultStatusCodeHandler.cs" />
<Compile Include="IStatusCodeHandler.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.