-
Notifications
You must be signed in to change notification settings - Fork 3
/
SurfaceControllerTests.cs
44 lines (38 loc) · 1.5 KB
/
SurfaceControllerTests.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 System.Web.Mvc;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Web;
using UmbracoUnitTesting.Core.Features.Hero;
using UmbracoUnitTesting.Tests.Shared;
namespace UmbracoUnitTesting.Tests.SurfaceController {
/// <summary>
/// Docs: https://our.umbraco.com/documentation/Implementation/Unit-Testing/#testing-a-surfacecontroller
/// </summary>
public class SurfaceControllerTests {
[TestFixture]
public class MySurfaceControllerTests : UmbracoBaseTest {
private HeroController controller;
[SetUp]
public override void SetUp()
{
base.SetUp();
this.controller = new HeroController(Mock.Of<IUmbracoContextAccessor>(), Mock.Of<IUmbracoDatabaseFactory>(), base.ServiceContext, AppCaches.NoCache, Mock.Of<ILogger>(), Mock.Of<IProfilingLogger>(), base.UmbracoHelper);
}
[Test]
public void WhenIndexAction_ThenResultIsIsAssignableFromContentResult()
{
var result = this.controller.Index();
Assert.IsAssignableFrom<ContentResult>(result);
}
[Test]
public void GivenResultIsAssignableFromContentResult_WhenIndexAction_ThenContentIsExpected()
{
var result = (ContentResult)this.controller.Index();
Assert.AreEqual("Hello World", result.Content);
}
}
}
}