forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartialExtensionsTest.cs
More file actions
88 lines (75 loc) · 3.83 KB
/
Copy pathPartialExtensionsTest.cs
File metadata and controls
88 lines (75 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Microsoft.TestCommon;
namespace System.Web.Mvc.Html.Test
{
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")]
public class PartialExtensionsTest
{
[Fact]
public void PartialWithViewName()
{
// Arrange
RenderPartialExtensionsTest.SpyHtmlHelper helper = RenderPartialExtensionsTest.SpyHtmlHelper.Create();
// Act
MvcHtmlString result = helper.Partial("partial-view");
// Assert
Assert.Equal("partial-view", helper.RenderPartialInternal_PartialViewName);
Assert.Same(helper.ViewData, helper.RenderPartialInternal_ViewData);
Assert.Null(helper.RenderPartialInternal_Model);
Assert.IsType<StringWriter>(helper.RenderPartialInternal_Writer);
Assert.Same(ViewEngines.Engines, helper.RenderPartialInternal_ViewEngineCollection);
Assert.Equal("This is the result of the view", result.ToHtmlString());
}
[Fact]
public void PartialWithViewNameAndViewData()
{
// Arrange
RenderPartialExtensionsTest.SpyHtmlHelper helper = RenderPartialExtensionsTest.SpyHtmlHelper.Create();
ViewDataDictionary viewData = new ViewDataDictionary();
// Act
MvcHtmlString result = helper.Partial("partial-view", viewData);
// Assert
Assert.Equal("partial-view", helper.RenderPartialInternal_PartialViewName);
Assert.Same(viewData, helper.RenderPartialInternal_ViewData);
Assert.Null(helper.RenderPartialInternal_Model);
Assert.IsType<StringWriter>(helper.RenderPartialInternal_Writer);
Assert.Same(ViewEngines.Engines, helper.RenderPartialInternal_ViewEngineCollection);
Assert.Equal("This is the result of the view", result.ToHtmlString());
}
[Fact]
public void PartialWithViewNameAndModel()
{
// Arrange
RenderPartialExtensionsTest.SpyHtmlHelper helper = RenderPartialExtensionsTest.SpyHtmlHelper.Create();
object model = new object();
// Act
MvcHtmlString result = helper.Partial("partial-view", model);
// Assert
Assert.Equal("partial-view", helper.RenderPartialInternal_PartialViewName);
Assert.Same(helper.ViewData, helper.RenderPartialInternal_ViewData);
Assert.Same(model, helper.RenderPartialInternal_Model);
Assert.IsType<StringWriter>(helper.RenderPartialInternal_Writer);
Assert.Same(ViewEngines.Engines, helper.RenderPartialInternal_ViewEngineCollection);
Assert.Equal("This is the result of the view", result.ToHtmlString());
}
[Fact]
public void PartialWithViewNameAndModelAndViewData()
{
// Arrange
RenderPartialExtensionsTest.SpyHtmlHelper helper = RenderPartialExtensionsTest.SpyHtmlHelper.Create();
object model = new object();
ViewDataDictionary viewData = new ViewDataDictionary();
// Act
MvcHtmlString result = helper.Partial("partial-view", model, viewData);
// Assert
Assert.Equal("partial-view", helper.RenderPartialInternal_PartialViewName);
Assert.Same(viewData, helper.RenderPartialInternal_ViewData);
Assert.Same(model, helper.RenderPartialInternal_Model);
Assert.IsType<StringWriter>(helper.RenderPartialInternal_Writer);
Assert.Same(ViewEngines.Engines, helper.RenderPartialInternal_ViewEngineCollection);
Assert.Equal("This is the result of the view", result.ToHtmlString());
}
}
}