-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathContentModelTests.cs
50 lines (43 loc) · 1.7 KB
/
ContentModelTests.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
using Moq;
using NUnit.Framework;
using Umbraco.Core.Models.PublishedContent;
using UmbracoUnitTesting.Core.Features.Home;
using UmbracoUnitTesting.Core.Features.StandardPage;
using UmbracoUnitTesting.Tests.Shared;
namespace UmbracoUnitTesting.Tests.ContentModel {
/// <inheritdoc />
/// <summary>
/// Docs: https://our.umbraco.com/documentation/Implementation/Unit-Testing/#testing-a-contentmodel
/// </summary>
[TestFixture]
public class ContentModelTests : UmbracoBaseTest
{
[SetUp]
public override void SetUp()
{
base.SetUp();
}
[Test]
[TestCase("", "")]
[TestCase("My Heading", "My Heading")]
[TestCase("Another Heading", "Another Heading")]
public void GivenPublishedContent_WhenGetHeading_ThenReturnCustomViewModelWithHeadingValue(string value, string expected)
{
var publishedContent = new Mock<IPublishedContent>();
base.SetupPropertyValue(publishedContent, nameof(StandardPageViewModel.Heading), value);
var model = new StandardPageViewModel(publishedContent.Object);
Assert.AreEqual(expected, model.Heading);
}
[Test]
[TestCase("/", "/")]
[TestCase("/umbraco", "/umbraco")]
[TestCase("https://www.umbraco.com", "https://www.umbraco.com")]
public void GivenPublishedContent_WhenGetUrl_ThenReturnCustomViewModelWithUrl(string url, string expected)
{
var content = new Mock<IPublishedContent>();
content.Setup(x => x.Url).Returns(url);
var model = new StandardPageViewModel(content.Object);
Assert.AreEqual(expected, model.Url);
}
}
}