Created
August 17, 2019 04:37
-
-
Save takahirohonda/6ddf2d433b546f70ddcb9e934774541e to your computer and use it in GitHub Desktop.
how-to-mock-rendering-parameters-in-unit-test-sitecore-2.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FluentAssertions; | |
using Sitecore.Mvc.Presentation; | |
using SitecoreDev.Feature.Design.Models; | |
using SitecoreDev.Feature.Design.Repository; | |
using System.Collections.Generic; | |
using Xunit; | |
namespace SitecoreDev.Feature.Design.Tests.RepositoryTests | |
{ | |
public class CustomDataDivRepositoryTests | |
{ | |
[Fact] | |
public void GetParamsForCustomDiv_Should_Return_Correct_Model() | |
{ | |
// Arrange | |
// Create mock parameters | |
var parameters = new RenderingParameters("hey=hello&more=moreValues"); | |
// Create expected model | |
var expectedModel = new CustomDataDiv() | |
{ | |
CustomData = new Dictionary<string, string> | |
{ | |
{ "hey", "hello" }, | |
{ "more", "moreValues" } | |
} | |
}; | |
// Instantiate the class | |
var repository = new CustomDataDivRepository(); | |
// Act | |
var model = repository.GetParamsForCustomDiv(parameters); | |
// Assert | |
model.Should().BeEquivalentTo(expectedModel); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment