Skip to content

Commit 171e0b4

Browse files
committedJan 1, 2015
Add test for null model value.
1 parent 1d813e8 commit 171e0b4

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
 

‎test/WebApiContrib.Formatting.Razor.Tests/ViewEngineTests.cs

+12
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ public async Task render_simple_template()
4545
Assert.AreEqual("Hello foo! Welcome to Razor!", output);
4646
}
4747

48+
[Test]
49+
public async Task render_simple_template_with_no_model()
50+
{
51+
var cts = new CancellationTokenSource();
52+
var view = new ViewResult(_request, "TestNull", null);
53+
54+
var response = await view.ExecuteAsync(cts.Token);
55+
var output = await response.Content.ReadAsStringAsync();
56+
57+
Assert.AreEqual("Hello foo! Welcome to Razor!", output);
58+
}
59+
4860
[Test]
4961
public async Task render_template_with_embedded_layout()
5062
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello foo! Welcome to Razor!

‎test/WebApiContrib.Formatting.Razor.Tests/WebApiContrib.Razor.Tests.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,17 @@
7878
<EmbeddedResource Include="Views\Test1.cshtml" />
7979
<EmbeddedResource Include="Views\Test2.cshtml" />
8080
<None Include="packages.config" />
81+
<EmbeddedResource Include="Views\TestNull.cshtml" />
8182
</ItemGroup>
8283
<ItemGroup>
8384
<ProjectReference Include="..\..\src\WebApiContrib.Formatting.Razor\WebApiContrib.Formatting.Razor.csproj">
8485
<Project>{8C15B0D3-9108-4EA3-AE19-3C9571266C47}</Project>
8586
<Name>WebApiContrib.Formatting.Razor</Name>
8687
</ProjectReference>
8788
</ItemGroup>
89+
<ItemGroup>
90+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
91+
</ItemGroup>
8892
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8993
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
9094
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

0 commit comments

Comments
 (0)