-
Notifications
You must be signed in to change notification settings - Fork 4
/
ContentModelTests.cs
29 lines (25 loc) · 1.06 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
using AutoFixture.NUnit3;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco10Testing.Tests.Features;
namespace Umbraco10Testing.Tests
{
public class ContentModelTests
{
[Test, AutoData]
public void Given_PublishedContent_When_GetHeading_Then_ReturnPageViewModelWithHeading(string value, Mock<IPublishedContent> content)
{
SetupPropertyValue(content, nameof(PageViewModel.Heading), value);
var viewModel = new PageViewModel(content.Object);
Assert.AreEqual(value, viewModel.Heading);
}
public void SetupPropertyValue(Mock<IPublishedContent> content, string propertyAlias, string propertyValue, string culture = null)
{
var property = new Mock<IPublishedProperty>();
property.Setup(x => x.Alias).Returns(nameof(PageViewModel.Heading));
property.Setup(x => x.GetValue(culture, null)).Returns(propertyValue);
content.Setup(x => x.GetProperty(propertyAlias)).Returns(property.Object);
}
}
}