forked from Adolfi/UmbracoNineDemoSite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FooterViewComponentTests.cs
74 lines (59 loc) · 2.8 KB
/
FooterViewComponentTests.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
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
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Extensions;
using UmbracoNineDemoSite.Core.Features.Shared.Components.Footer;
using UmbracoNineDemoSite.Core.Features.Shared.Settings;
namespace UmbracoNineDemoSite.Tests.Unit.Features.Shared.Components.Footer
{
[TestFixture]
public class FooterViewComponentTests
{
private Mock<ISiteSettings> siteSettings;
private FooterViewComponent footerViewComponent;
[SetUp]
public void SetUp()
{
this.siteSettings = new Mock<ISiteSettings>();
this.footerViewComponent = new FooterViewComponent(this.siteSettings.Object);
}
[Test]
[TestCase("header")]
[TestCase("heading")]
public void Given_SiteSettingsHasCallToActionHeader_When_Invoke_Then_ReturnViewModelWithCallToActionHeader(string expected)
{
this.siteSettings.Setup(x => x.CallToActionHeader).Returns(expected);
var model = (FooterViewModel)((ViewViewComponentResult)this.footerViewComponent.Invoke()).ViewData.Model;
Assert.AreEqual(expected, model.CallToActionHeader);
}
[Test]
[TestCase("description")]
[TestCase("descriptor")]
public void Given_SiteSettingsHasCallToActionDescription_When_Invoke_Then_ReturnViewModelWithCallToActionDescription(string expected)
{
this.siteSettings.Setup(x => x.CallToActionDescription).Returns(expected);
var model = (FooterViewModel)((ViewViewComponentResult)this.footerViewComponent.Invoke()).ViewData.Model;
Assert.AreEqual(expected, model.CallToActionDescription);
}
[Test]
[TestCase("button")]
[TestCase("label")]
public void Given_SiteSettingsHasCallToActionButtonLabel_When_Invoke_Then_ReturnViewModelWithCallToActionButtonLabel(string expected)
{
this.siteSettings.Setup(x => x.CallToActionButtonLabel).Returns(expected);
var model = (FooterViewModel)((ViewViewComponentResult)this.footerViewComponent.Invoke()).ViewData.Model;
Assert.AreEqual(expected, model.CallToActionButtonLabel);
}
[Test]
[TestCase("footer")]
[TestCase("text")]
public void Given_SiteSettingsHasFooterText_When_Invoke_Then_ReturnViewModelWithText(string expected)
{
this.siteSettings.Setup(x => x.FooterText).Returns(expected);
var model = (FooterViewModel)((ViewViewComponentResult)this.footerViewComponent.Invoke()).ViewData.Model;
Assert.AreEqual(expected, model.Text);
}
// TODO: Add test for CallToActionUrl. Just have to figure out how to mock the Url() extension method in v9.
}
}