This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Mocking controllers and views
Alexanderius edited this page Jun 30, 2019
·
3 revisions
Mocking of views and controllers available by default because all controller base properties are virtual, your can use mocking frameworks such as Moq to do mocking.
Testing what default controller returns StaticTpl
with "Default" template name to load.
[Get("/")]
public class DefaultController : Controller
{
public override ControllerResponse Invoke()
{
return new StaticTpl("Default");
}
}
[TestFixture]
public class DefaultPageControllerTests
{
[Test]
public void Invoke_Default_MainContentSet()
{
// Assign
var c = new Mock<DefaultController> {CallBase = true};
// Act
var result = c.Object.Invoke();
// Assert
Assert.AreEqual("Default", ((StaticTpl)result).TemplateFileName);
}
}
- Getting Started
- Main Simplify.Web principles
- Simplify.Web controllers
- Simplify.Web views
- Simplify.Web templates
- Simplify.Web configuration
- Templates variables
- Static content
- Template factory
- Data collector
- String table
- File reader
- Web context
- Environment
- Language manager
- Redirector
- HTML