Skip to content

Commit 1fee635

Browse files
committed
Added unit tests for the view bag with builder - for containing multiple entries, for containing entry with key and for containing entry of type.
1 parent 59e6339 commit 1fee635

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/MyTested.AspNetCore.Mvc.ViewData.Test/BuildersTests/ActionsTests/ShouldHaveTests/ShouldHaveViewBagTests.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,47 @@ public void ViewBagWithBuilderShouldWorkCorrectly()
131131
.ShouldReturn()
132132
.Ok();
133133
}
134+
135+
[Fact]
136+
public void ViewBagWithBuilderShouldContainMultipleEntries()
137+
{
138+
MyController<MvcController>
139+
.Instance()
140+
.Calling(c => c.AddViewBagAction())
141+
.ShouldHave()
142+
.ViewBag(viewBag => viewBag
143+
.ContainingEntries(new { Test = "BagValue", Another = "AnotherValue" }))
144+
.AndAlso()
145+
.ShouldReturn()
146+
.Ok();
147+
}
148+
149+
[Fact]
150+
public void ViewBagWithBuilderShouldContainEntryWithKey()
151+
{
152+
MyController<MvcController>
153+
.Instance()
154+
.Calling(c => c.AddViewBagAction())
155+
.ShouldHave()
156+
.ViewBag(viewBag => viewBag
157+
.ContainingEntryWithKey("Another"))
158+
.AndAlso()
159+
.ShouldReturn()
160+
.Ok();
161+
}
162+
163+
[Fact]
164+
public void ViewBagWithBuilderShouldContainEntryOfTypeString()
165+
{
166+
MyController<MvcController>
167+
.Instance()
168+
.Calling(c => c.AddViewBagAction())
169+
.ShouldHave()
170+
.ViewBag(viewBag => viewBag
171+
.ContainingEntryOfType<string>())
172+
.AndAlso()
173+
.ShouldReturn()
174+
.Ok();
175+
}
134176
}
135177
}

0 commit comments

Comments
 (0)