Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

failing test

  • Loading branch information...
commit 9873c61ccb9e006abafa65f9fac5a1dbf2ea1a4a 1 parent f81a7f9
@thefringeninja thefringeninja authored
Showing with 37 additions and 1 deletion.
  1. +37 −1 src/Nancy.ViewEngines.Razor.Tests/RazorViewEngineFixture.cs
View
38 src/Nancy.ViewEngines.Razor.Tests/RazorViewEngineFixture.cs
@@ -1,4 +1,6 @@
-namespace Nancy.ViewEngines.Razor.Tests
+using System.Threading;
+
+namespace Nancy.ViewEngines.Razor.Tests
{
using System;
using System.Dynamic;
@@ -468,6 +470,40 @@ public void Should_use_custom_view_base_with_vb_views()
output.ShouldEqual("<h1>Hi, Nancy!</h1>");
}
+ [Fact]
+ public void should_work_on_multiple_threads()
+ {
+ // Given
+ var location = new ViewLocationResult(
+ string.Empty,
+ string.Empty,
+ "cshtml",
+ () =>
+ {
+ Thread.Sleep(500);
+ return new StringReader(@"@{var x = ""test"";}<h1>Hello Mr. @x</h1>");
+ });
+
+ var wait = new ManualResetEvent(false);
+
+ var stream = new MemoryStream();
+
+ // When
+ ThreadPool.QueueUserWorkItem(_ =>
+ {
+ var response2 = this.engine.RenderView(location, null, this.renderContext);
+ response2.Contents.Invoke(new MemoryStream());
+ wait.Set();
+ });
+ var response = this.engine.RenderView(location, null, this.renderContext);
+ response.Contents.Invoke(stream);
+
+ wait.WaitOne(1000).ShouldBeTrue();
+
+ // Then
+ stream.ShouldEqual("<h1>Hello Mr. test</h1>");
+ }
+
private static string ReadAll(Stream stream)
{
stream.Position = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.