forked from Adolfi/UmbracoNineDemoSite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
HeaderViewComponentTests.cs
44 lines (37 loc) · 1.49 KB
/
HeaderViewComponentTests.cs
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
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Moq;
using NUnit.Framework;
using UmbracoNineDemoSite.Core.Features.Shared.Components.Header;
using UmbracoNineDemoSite.Core.Features.Shared.Settings;
namespace UmbracoNineDemoSite.Tests.Unit.Features.Shared.Components.Footer
{
[TestFixture]
public class HeaderViewComponentTests
{
private Mock<ISiteSettings> siteSettings;
private HeaderViewComponent headerViewComponent;
[SetUp]
public void SetUp()
{
this.siteSettings = new Mock<ISiteSettings>();
this.headerViewComponent = new HeaderViewComponent(this.siteSettings.Object);
}
[Test]
[TestCase("siteName")]
[TestCase("Umbraco 9 Demo")]
public void Given_SiteSettingsHasSiteName_When_Invoke_Then_ReturnViewModelWithHeading(string siteName)
{
this.siteSettings.Setup(x => x.SiteName).Returns(siteName);
var model = (HeaderViewModel)((ViewViewComponentResult)this.headerViewComponent.Invoke(0)).ViewData.Model;
Assert.AreEqual(siteName, model.Heading);
}
[Test]
[TestCase(1)]
[TestCase(12)]
public void Given_SelectedParameter_When_Invoke_Then_ReturnViewModelWithSelectedValue(int selected)
{
var model = (HeaderViewModel)((ViewViewComponentResult)this.headerViewComponent.Invoke(selected)).ViewData.Model;
Assert.AreEqual(selected, model.Selected);
}
}
}